├── .gitignore ├── FreeIOT.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── FreeIOT ├── AppDelegate │ ├── AppDelegate.h │ └── AppDelegate.m ├── Class │ ├── NSString+URLEncode.h │ └── NSString+URLEncode.m ├── Common │ └── Const.h ├── Images.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── cloud-60@2x-1.png │ │ ├── cloud-60@2x.png │ │ ├── cloud-60@3x.png │ │ ├── cloud-76.png │ │ ├── cloud-76@2x.png │ │ ├── cloud-Small-40.png │ │ ├── cloud-Small-40@2x-1.png │ │ ├── cloud-Small-40@2x.png │ │ ├── cloud-Small.png │ │ ├── cloud-Small@2x-1.png │ │ ├── cloud-Small@2x.png │ │ └── cloud-Small@3x.png │ ├── LaunchImage.launchimage │ │ ├── 1242x2208.png │ │ ├── 640x1136.png │ │ ├── 640x960.png │ │ ├── 750x1334.png │ │ └── Contents.json │ ├── auth.imageset │ │ ├── Contents.json │ │ ├── auth@1x.png │ │ └── auth@2x.png │ ├── menu.imageset │ │ ├── Contents.json │ │ └── MenuBack@2x.png │ ├── modify.imageset │ │ ├── Contents.json │ │ ├── modify@1x.png │ │ └── modify@2x.png │ ├── profile.imageset │ │ ├── Contents.json │ │ └── IconProfile48@2x.png │ ├── settings_red.imageset │ │ ├── Contents.json │ │ └── settings_red@2x.png │ ├── settings_yellow.imageset │ │ ├── Contents.json │ │ └── settings_yellow@2x.png │ └── unbind.imageset │ │ ├── Contents.json │ │ ├── unbind@1x.png │ │ └── unbind@2x.png ├── Info.plist ├── Lib │ ├── CHKeychain.h │ ├── CHKeychain.m │ ├── HttpApi.h │ ├── HttpApi.m │ ├── MBProgressHUD.h │ ├── MBProgressHUD.m │ ├── PopMenu │ │ ├── GlowImageView.h │ │ ├── GlowImageView.m │ │ ├── MenuButton.h │ │ ├── MenuButton.m │ │ ├── MenuItem.h │ │ ├── MenuItem.m │ │ ├── PopMenu.h │ │ ├── PopMenu.m │ │ ├── XHRealTimeBlur │ │ │ ├── XHRealTimeBlur.h │ │ │ └── XHRealTimeBlur.m │ │ └── pop │ │ │ ├── POP.h │ │ │ ├── POPAction.h │ │ │ ├── POPAnimatableProperty.h │ │ │ ├── POPAnimatableProperty.mm │ │ │ ├── POPAnimation.h │ │ │ ├── POPAnimation.mm │ │ │ ├── POPAnimationEvent.h │ │ │ ├── POPAnimationEvent.mm │ │ │ ├── POPAnimationEventInternal.h │ │ │ ├── POPAnimationExtras.h │ │ │ ├── POPAnimationExtras.mm │ │ │ ├── POPAnimationInternal.h │ │ │ ├── POPAnimationPrivate.h │ │ │ ├── POPAnimationRuntime.h │ │ │ ├── POPAnimationRuntime.mm │ │ │ ├── POPAnimationTracer.h │ │ │ ├── POPAnimationTracer.mm │ │ │ ├── POPAnimationTracerInternal.h │ │ │ ├── POPAnimator.h │ │ │ ├── POPAnimator.mm │ │ │ ├── POPAnimatorPrivate.h │ │ │ ├── POPBasicAnimation.h │ │ │ ├── POPBasicAnimation.mm │ │ │ ├── POPBasicAnimationInternal.h │ │ │ ├── POPCGUtils.h │ │ │ ├── POPCGUtils.mm │ │ │ ├── POPCustomAnimation.h │ │ │ ├── POPCustomAnimation.mm │ │ │ ├── POPDecayAnimation.h │ │ │ ├── POPDecayAnimation.mm │ │ │ ├── POPDecayAnimationInternal.h │ │ │ ├── POPDefines.h │ │ │ ├── POPGeometry.h │ │ │ ├── POPGeometry.mm │ │ │ ├── POPLayerExtras.h │ │ │ ├── POPLayerExtras.mm │ │ │ ├── POPMath.h │ │ │ ├── POPMath.mm │ │ │ ├── POPPropertyAnimation.h │ │ │ ├── POPPropertyAnimation.mm │ │ │ ├── POPPropertyAnimationInternal.h │ │ │ ├── POPSpringAnimation.h │ │ │ ├── POPSpringAnimation.mm │ │ │ ├── POPSpringAnimationInternal.h │ │ │ ├── POPSpringSolver.h │ │ │ ├── POPVector.h │ │ │ ├── POPVector.mm │ │ │ └── WebCore │ │ │ ├── FloatConversion.h │ │ │ ├── TransformationMatrix.cpp │ │ │ ├── TransformationMatrix.h │ │ │ └── UnitBezier.h │ ├── RESideMenu │ │ ├── RECommonFunctions.h │ │ ├── RECommonFunctions.m │ │ ├── RESideMenu.h │ │ ├── RESideMenu.m │ │ ├── UIViewController+RESideMenu.h │ │ └── UIViewController+RESideMenu.m │ ├── WebViewJavascriptBridge.h │ └── WebViewJavascriptBridge.m ├── PandoSdk.framework │ ├── Headers │ │ └── PandoSdk.h │ ├── Info.plist │ ├── Modules │ │ └── module.modulemap │ ├── PandoSdk │ └── _CodeSignature │ │ └── CodeResources ├── View │ ├── AddDeviceViewController.h │ ├── AddDeviceViewController.m │ ├── ChangePassViewController.h │ ├── ChangePassViewController.m │ ├── DeviceAuthViewController.h │ ├── DeviceAuthViewController.m │ ├── DeviceDetailViewController.h │ ├── DeviceDetailViewController.m │ ├── DevicePermissionViewController.h │ ├── DevicePermissionViewController.m │ ├── LoginViewController.h │ ├── LoginViewController.m │ ├── Main.storyboard │ ├── ModifyDeviceViewController.h │ ├── ModifyDeviceViewController.m │ ├── MyDevicesViewController.h │ ├── MyDevicesViewController.m │ ├── ProfileMenuViewController.h │ ├── ProfileMenuViewController.m │ ├── RegisterViewController.h │ ├── RegisterViewController.m │ ├── RootViewController.h │ └── RootViewController.m ├── en.lproj │ └── Strings.strings ├── main.m └── zh-Hans.lproj │ └── Strings.strings ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /FreeIOT.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /FreeIOT/AppDelegate/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/3/11. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /FreeIOT/Class/NSString+URLEncode.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+URLEncode.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/3/19. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSString (URLEncode) 12 | 13 | - (NSString *)URLEncodedString; 14 | - (NSString *)URLDecodedString; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /FreeIOT/Class/NSString+URLEncode.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+URLEncode.m 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/3/19. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import "NSString+URLEncode.h" 10 | 11 | @implementation NSString (URLEncode) 12 | 13 | - (NSString *)URLEncodedString 14 | { 15 | NSString *result = ( NSString *) 16 | CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, 17 | (CFStringRef)self, 18 | NULL, 19 | CFSTR("!*();+$,%#[] "), 20 | kCFStringEncodingUTF8)); 21 | return result; 22 | } 23 | 24 | - (NSString*)URLDecodedString 25 | { 26 | NSString *result = ( NSString *) 27 | CFBridgingRelease(CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault, 28 | (CFStringRef)self, 29 | CFSTR(""), 30 | kCFStringEncodingUTF8)); 31 | return result; 32 | } 33 | 34 | @end -------------------------------------------------------------------------------- /FreeIOT/Common/Const.h: -------------------------------------------------------------------------------- 1 | // 2 | // Const.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/3/14. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #ifndef OutletApp_Const_h 10 | #define OutletApp_Const_h 11 | 12 | #ifndef __OPTIMIZE__ 13 | #define NSLog(...) NSLog(__VA_ARGS__) 14 | #else 15 | #define NSLog(...) {} 16 | #endif 17 | 18 | //#define HOST_URL @"https://api.pandocloud.com" 19 | #define HOST_URL_FORMAL @"https://api.pandocloud.com" 20 | #define HOST_URL_TEST @"https://testapi.pandocloud.com" 21 | #define HOST_URL_STAGE @"https://stageapi.pandocloud.com" 22 | 23 | #define LOGIN_PATH @"/v1/users/authentication" 24 | #define LOGOUT_PATH @"/v1/users/logout" 25 | #define REGISTER_PATH @"/v1/users/registration" 26 | #define PASS_RESET_PATH @"/v1/users/reset" 27 | #define GET_AUTH_CODE @"/v1/users/verification" 28 | #define CHANGE_PASS_PATH @"/v1/users/password" 29 | 30 | #define GET_DEVICES_PATH @"/v1/devices" 31 | #define BIND_DEVICE_PATH @"/v1/devices/binding" 32 | #define DEVICE_REGSTER_PATH @"/v1/devices/registration" 33 | #define DEVICE_LOGIN_PATH @"/v1/devices/authentication" 34 | #define SET_DEVICE_VALUE @"/v1/devices/%@/commands" 35 | #define DEVICE_STATUS @"/v1/devices/%@/status/current" 36 | #define SET_DEVICE_STATUS @"/v1/devices/%@/status" 37 | #define ALLOW_PERMITIONS @"/v1/devices/%@/permissions" 38 | #define DEVICE_UNBIND_PATH @"/v1/devices/%@/unbinding" 39 | #define MODIFY_DEVICE_PATH @"/v1/devices/%@" 40 | #define DEVICE_USERS_PATH @"/v1/devices/%@/permissions" 41 | #define DELETE_USER_PATH @"/v1/devices/%@/permissions/%@" 42 | #define DEVICE_DELETE_PATH @"/v1/devices/%@" 43 | 44 | #define PRODUCT_INFO @"/v1/product/info" 45 | 46 | #define VENDOR_KEY @"570f93557db3532727b54336e47f1a3500b3c0e564" 47 | //#define PRODUCT_KEY @"4518befdb4c18f0061c642b8637d687aa8c4bb9165" 48 | #define PRODUCT_KEY @"f07fd3f2782ff4964b74d51e89ad0aabf0192ec066" 49 | #define DEVICE_PRODUCT_KEY @"f07fd3f2782ff4964b74d51e89ad0aabf0192ec066" 50 | 51 | #define LocalStr(a) NSLocalizedStringFromTable(a, @"Strings", nil) 52 | 53 | #define KEY_PUSH_TOKEN @"push_token" 54 | #define KEY_ACCESS_TOKEN @"access_token" 55 | #define KEY_DEVICE_REGISTERED @"devcie_registered" 56 | #define KEY_DEVICE_ID @"device_id" 57 | #define KEY_DEVICE_SECRET @"device_secret" 58 | #define KEY_DEVICE_KEY @"device_key" 59 | #define KEY_DEVICE_BINDED @"device_binded" 60 | #define KEY_PRODUCT_INFO @"product_info" 61 | 62 | #define AP_SSID @"freeiot" //[self.productInfo objectForKey:@"code"] 63 | 64 | #define IS_MAIL NO 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "cloud-Small@2x-1.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "cloud-Small@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "iphone", 18 | "filename" : "cloud-Small-40@2x.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "cloud-60@2x-1.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "60x60", 29 | "idiom" : "iphone", 30 | "filename" : "cloud-60@2x.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "cloud-60@3x.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "29x29", 41 | "idiom" : "ipad", 42 | "filename" : "cloud-Small.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "29x29", 47 | "idiom" : "ipad", 48 | "filename" : "cloud-Small@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "40x40", 53 | "idiom" : "ipad", 54 | "filename" : "cloud-Small-40.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "40x40", 59 | "idiom" : "ipad", 60 | "filename" : "cloud-Small-40@2x-1.png", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "size" : "76x76", 65 | "idiom" : "ipad", 66 | "filename" : "cloud-76.png", 67 | "scale" : "1x" 68 | }, 69 | { 70 | "size" : "76x76", 71 | "idiom" : "ipad", 72 | "filename" : "cloud-76@2x.png", 73 | "scale" : "2x" 74 | } 75 | ], 76 | "info" : { 77 | "version" : 1, 78 | "author" : "xcode" 79 | } 80 | } -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-60@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-60@2x-1.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-60@2x.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-60@3x.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-76.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-76@2x.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-Small-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-Small-40.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-Small-40@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-Small-40@2x-1.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-Small-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-Small-40@2x.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-Small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-Small.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-Small@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-Small@2x-1.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-Small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-Small@2x.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-Small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/AppIcon.appiconset/cloud-Small@3x.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/LaunchImage.launchimage/1242x2208.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/LaunchImage.launchimage/1242x2208.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/LaunchImage.launchimage/640x1136.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/LaunchImage.launchimage/640x1136.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/LaunchImage.launchimage/640x960.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/LaunchImage.launchimage/640x960.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/LaunchImage.launchimage/750x1334.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/LaunchImage.launchimage/750x1334.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "extent" : "full-screen", 5 | "idiom" : "iphone", 6 | "subtype" : "736h", 7 | "filename" : "1242x2208.png", 8 | "minimum-system-version" : "8.0", 9 | "orientation" : "portrait", 10 | "scale" : "3x" 11 | }, 12 | { 13 | "orientation" : "landscape", 14 | "idiom" : "iphone", 15 | "extent" : "full-screen", 16 | "minimum-system-version" : "8.0", 17 | "subtype" : "736h", 18 | "scale" : "3x" 19 | }, 20 | { 21 | "extent" : "full-screen", 22 | "idiom" : "iphone", 23 | "subtype" : "667h", 24 | "filename" : "750x1334.png", 25 | "minimum-system-version" : "8.0", 26 | "orientation" : "portrait", 27 | "scale" : "2x" 28 | }, 29 | { 30 | "orientation" : "portrait", 31 | "idiom" : "iphone", 32 | "extent" : "full-screen", 33 | "minimum-system-version" : "7.0", 34 | "filename" : "640x960.png", 35 | "scale" : "2x" 36 | }, 37 | { 38 | "extent" : "full-screen", 39 | "idiom" : "iphone", 40 | "subtype" : "retina4", 41 | "filename" : "640x1136.png", 42 | "minimum-system-version" : "7.0", 43 | "orientation" : "portrait", 44 | "scale" : "2x" 45 | }, 46 | { 47 | "orientation" : "portrait", 48 | "idiom" : "ipad", 49 | "extent" : "full-screen", 50 | "minimum-system-version" : "7.0", 51 | "scale" : "1x" 52 | }, 53 | { 54 | "orientation" : "landscape", 55 | "idiom" : "ipad", 56 | "extent" : "full-screen", 57 | "minimum-system-version" : "7.0", 58 | "scale" : "1x" 59 | }, 60 | { 61 | "orientation" : "portrait", 62 | "idiom" : "ipad", 63 | "extent" : "full-screen", 64 | "minimum-system-version" : "7.0", 65 | "scale" : "2x" 66 | }, 67 | { 68 | "orientation" : "landscape", 69 | "idiom" : "ipad", 70 | "extent" : "full-screen", 71 | "minimum-system-version" : "7.0", 72 | "scale" : "2x" 73 | }, 74 | { 75 | "orientation" : "portrait", 76 | "idiom" : "iphone", 77 | "extent" : "full-screen", 78 | "scale" : "1x" 79 | }, 80 | { 81 | "orientation" : "portrait", 82 | "idiom" : "iphone", 83 | "extent" : "full-screen", 84 | "scale" : "2x" 85 | }, 86 | { 87 | "orientation" : "portrait", 88 | "idiom" : "iphone", 89 | "extent" : "full-screen", 90 | "subtype" : "retina4", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "orientation" : "portrait", 95 | "idiom" : "ipad", 96 | "extent" : "to-status-bar", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "orientation" : "portrait", 101 | "idiom" : "ipad", 102 | "extent" : "full-screen", 103 | "scale" : "1x" 104 | }, 105 | { 106 | "orientation" : "landscape", 107 | "idiom" : "ipad", 108 | "extent" : "to-status-bar", 109 | "scale" : "1x" 110 | }, 111 | { 112 | "orientation" : "landscape", 113 | "idiom" : "ipad", 114 | "extent" : "full-screen", 115 | "scale" : "1x" 116 | }, 117 | { 118 | "orientation" : "portrait", 119 | "idiom" : "ipad", 120 | "extent" : "to-status-bar", 121 | "scale" : "2x" 122 | }, 123 | { 124 | "orientation" : "portrait", 125 | "idiom" : "ipad", 126 | "extent" : "full-screen", 127 | "scale" : "2x" 128 | }, 129 | { 130 | "orientation" : "landscape", 131 | "idiom" : "ipad", 132 | "extent" : "to-status-bar", 133 | "scale" : "2x" 134 | }, 135 | { 136 | "orientation" : "landscape", 137 | "idiom" : "ipad", 138 | "extent" : "full-screen", 139 | "scale" : "2x" 140 | } 141 | ], 142 | "info" : { 143 | "version" : 1, 144 | "author" : "xcode" 145 | } 146 | } -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/auth.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "auth@1x.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x", 11 | "filename" : "auth@2x.png" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/auth.imageset/auth@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/auth.imageset/auth@1x.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/auth.imageset/auth@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/auth.imageset/auth@2x.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/menu.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "MenuBack@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/menu.imageset/MenuBack@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/menu.imageset/MenuBack@2x.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/modify.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "modify@1x.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x", 11 | "filename" : "modify@2x.png" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/modify.imageset/modify@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/modify.imageset/modify@1x.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/modify.imageset/modify@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/modify.imageset/modify@2x.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/profile.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "IconProfile48@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/profile.imageset/IconProfile48@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/profile.imageset/IconProfile48@2x.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/settings_red.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "settings_red@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/settings_red.imageset/settings_red@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/settings_red.imageset/settings_red@2x.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/settings_yellow.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "settings_yellow@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/settings_yellow.imageset/settings_yellow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/settings_yellow.imageset/settings_yellow@2x.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/unbind.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "unbind@1x.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x", 11 | "filename" : "unbind@2x.png" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/unbind.imageset/unbind@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/unbind.imageset/unbind@1x.png -------------------------------------------------------------------------------- /FreeIOT/Images.xcassets/unbind.imageset/unbind@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/Images.xcassets/unbind.imageset/unbind@2x.png -------------------------------------------------------------------------------- /FreeIOT/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | FreeIOT 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 0.2.2 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 2.0 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | 32 | UIBackgroundModes 33 | 34 | remote-notification 35 | 36 | UIMainStoryboardFile 37 | Main 38 | UIRequiredDeviceCapabilities 39 | 40 | armv7 41 | 42 | UIStatusBarStyle 43 | UIStatusBarStyleLightContent 44 | UISupportedInterfaceOrientations 45 | 46 | UIInterfaceOrientationPortrait 47 | 48 | UISupportedInterfaceOrientations~ipad 49 | 50 | UIInterfaceOrientationPortrait 51 | UIInterfaceOrientationPortraitUpsideDown 52 | UIInterfaceOrientationLandscapeLeft 53 | UIInterfaceOrientationLandscapeRight 54 | 55 | UIViewControllerBasedStatusBarAppearance 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /FreeIOT/Lib/CHKeychain.h: -------------------------------------------------------------------------------- 1 | // 2 | // CHKeychain.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/3/21. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #ifndef OutletApp_CHKeychain_h 10 | #define OutletApp_CHKeychain_h 11 | 12 | #import 13 | 14 | @interface CHKeychain : NSObject 15 | 16 | + (void)save:(NSString *)service data:(id)data; 17 | + (id)load:(NSString *)service; 18 | + (void)delete:(NSString *)service; 19 | 20 | @end 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /FreeIOT/Lib/CHKeychain.m: -------------------------------------------------------------------------------- 1 | // 2 | // CHKeychain.m 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/3/21. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import "CHKeychain.h" 10 | 11 | @implementation CHKeychain 12 | 13 | + (NSMutableDictionary *)getKeychainQuery:(NSString *)service { 14 | return [NSMutableDictionary dictionaryWithObjectsAndKeys: 15 | (__bridge id)kSecClassGenericPassword,(__bridge id)kSecClass, 16 | service, (__bridge id)kSecAttrService, 17 | service, (__bridge id)kSecAttrAccount, 18 | (__bridge id)kSecAttrAccessibleAfterFirstUnlock,(__bridge id)kSecAttrAccessible, 19 | nil]; 20 | } 21 | 22 | + (void)save:(NSString *)service data:(id)data { 23 | //Get search dictionary 24 | NSMutableDictionary *keychainQuery = [self getKeychainQuery:service]; 25 | //Delete old item before add new item 26 | SecItemDelete((__bridge CFDictionaryRef)keychainQuery); 27 | //Add new object to search dictionary(Attention:the data format) 28 | [keychainQuery setObject:[NSKeyedArchiver archivedDataWithRootObject:data] forKey:(__bridge id)kSecValueData]; 29 | //Add item to keychain with the search dictionary 30 | SecItemAdd((__bridge CFDictionaryRef)keychainQuery, NULL); 31 | } 32 | 33 | + (id)load:(NSString *)service { 34 | id ret = nil; 35 | NSMutableDictionary *keychainQuery = [self getKeychainQuery:service]; 36 | //Configure the search setting 37 | //Since in our simple case we are expecting only a single attribute to be returned (the password) we can set the attribute kSecReturnData to kCFBooleanTrue 38 | [keychainQuery setObject:(id)kCFBooleanTrue forKey:(__bridge id)kSecReturnData]; 39 | [keychainQuery setObject:(__bridge id)kSecMatchLimitOne forKey:(__bridge id)kSecMatchLimit]; 40 | CFDataRef keyData = NULL; 41 | if (SecItemCopyMatching((__bridge CFDictionaryRef)keychainQuery, (CFTypeRef *)&keyData) == noErr) { 42 | @try { 43 | ret = [NSKeyedUnarchiver unarchiveObjectWithData:(__bridge NSData *)keyData]; 44 | } @catch (NSException *e) { 45 | NSLog(@"Unarchive of %@ failed: %@", service, e); 46 | } @finally { 47 | } 48 | } 49 | if (keyData) 50 | CFRelease(keyData); 51 | return ret; 52 | } 53 | 54 | + (void)delete:(NSString *)service { 55 | NSMutableDictionary *keychainQuery = [self getKeychainQuery:service]; 56 | SecItemDelete((__bridge CFDictionaryRef)keychainQuery); 57 | } 58 | @end 59 | -------------------------------------------------------------------------------- /FreeIOT/Lib/HttpApi.h: -------------------------------------------------------------------------------- 1 | // 2 | // HttpApi.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/3/14. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #ifndef OutletApp_HttpApi_h 10 | #define OutletApp_HttpApi_h 11 | 12 | @interface HttpApi : NSObject 13 | 14 | //接收从服务器返回数据。 15 | @property (strong, nonatomic) NSMutableData *data; 16 | 17 | -(void) request:(NSString *)reqUrl content:(NSString *)content; 18 | 19 | @end 20 | 21 | @interface NSString (URL) 22 | 23 | - (NSString *)URLEncodedString; 24 | - (NSString *)URLDecodedString; 25 | 26 | @end 27 | 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /FreeIOT/Lib/HttpApi.m: -------------------------------------------------------------------------------- 1 | // 2 | // HttpApi.m 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/3/14. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HttpApi.h" 11 | #import "Const.h" 12 | 13 | @interface HttpApi() 14 | 15 | @end 16 | 17 | @implementation HttpApi 18 | 19 | -(void) request:(NSString *)reqUrl content:(NSString *)content 20 | { 21 | NSURL *url = [NSURL URLWithString:[reqUrl URLEncodedString]]; 22 | NSString *method = @"GET"; 23 | 24 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; 25 | 26 | [request addValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; 27 | [request addValue:PRODUCT_KEY forHTTPHeaderField:@"Product-Key"]; 28 | 29 | if (content != nil) 30 | { 31 | [request setHTTPBody: [content dataUsingEncoding:NSUTF8StringEncoding]]; 32 | method = @"POST"; 33 | } 34 | 35 | [request setHTTPMethod:method]; 36 | 37 | NSOperationQueue *queue = [[NSOperationQueue alloc] init]; 38 | 39 | NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO]; 40 | [conn setDelegateQueue:queue]; 41 | [conn start]; 42 | 43 | if (conn) 44 | { 45 | NSLog(@"connect ok"); 46 | } 47 | else 48 | { 49 | NSLog(@"connect error"); 50 | } 51 | } 52 | 53 | #pragma mark - NSURLConnection 回调方法 54 | - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data 55 | { 56 | [self.data appendData:data]; 57 | 58 | NSLog(@"connection : didReceiveData"); 59 | } 60 | 61 | -(void) connection:(NSURLConnection *)connection didFailWithError: (NSError *)error 62 | { 63 | NSLog(@"Error (): %@", [error localizedDescription]); 64 | } 65 | 66 | - (void) connectionDidFinishLoading: (NSURLConnection*) connection 67 | { 68 | NSLog(@"请求完成..."); 69 | } 70 | 71 | 72 | @end 73 | 74 | 75 | 76 | 77 | @implementation NSString (URL) 78 | 79 | - (NSString *)URLEncodedString 80 | { 81 | NSString *result = ( NSString *) 82 | CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, 83 | (CFStringRef)self, 84 | NULL, 85 | CFSTR("!*();+$,%#[] "), 86 | kCFStringEncodingUTF8)); 87 | return result; 88 | } 89 | 90 | - (NSString*)URLDecodedString 91 | { 92 | NSString *result = ( NSString *) 93 | CFBridgingRelease(CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault, 94 | (CFStringRef)self, 95 | CFSTR(""), 96 | kCFStringEncodingUTF8)); 97 | return result; 98 | } 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/GlowImageView.h: -------------------------------------------------------------------------------- 1 | // 2 | // GlowImageView.h 3 | // JackFastKit 4 | // 5 | // Created by 曾 宪华 on 14-10-13. 6 | // Copyright (c) 2014年 华捷 iOS软件开发工程师 曾宪华. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GlowImageView : UIButton 12 | 13 | @property (nonatomic, assign) CGSize glowOffset; 14 | @property (nonatomic, assign) CGFloat glowAmount; 15 | @property (nonatomic, strong) UIColor *glowColor; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/GlowImageView.m: -------------------------------------------------------------------------------- 1 | // 2 | // GlowImageView.m 3 | // JackFastKit 4 | // 5 | // Created by 曾 宪华 on 14-10-13. 6 | // Copyright (c) 2014年 华捷 iOS软件开发工程师 曾宪华. All rights reserved. 7 | // 8 | 9 | #import "GlowImageView.h" 10 | 11 | @interface GlowImageView () { 12 | CGColorSpaceRef colorSpaceRef; 13 | CGColorRef glowColorRef; 14 | } 15 | 16 | @end 17 | 18 | @implementation GlowImageView 19 | 20 | - (void)setGlowColor:(UIColor *)newGlowColor { 21 | if (newGlowColor != _glowColor) { 22 | CGColorRelease(glowColorRef); 23 | 24 | _glowColor = newGlowColor; 25 | glowColorRef = CGColorCreate(colorSpaceRef, CGColorGetComponents(_glowColor.CGColor)); 26 | } 27 | [self setNeedsDisplay]; 28 | } 29 | 30 | - (id)initWithFrame:(CGRect)frame { 31 | self = [super initWithFrame:frame]; 32 | if (self) { 33 | // Initialization code 34 | colorSpaceRef = CGColorSpaceCreateDeviceRGB(); 35 | 36 | self.glowOffset = CGSizeMake(0.0, 0.0); 37 | self.glowAmount = 30.0; 38 | self.glowColor = [UIColor greenColor]; 39 | } 40 | return self; 41 | } 42 | 43 | - (void)dealloc { 44 | CGColorRelease(glowColorRef); 45 | CGColorSpaceRelease(colorSpaceRef); 46 | } 47 | 48 | // Only override drawRect: if you perform custom drawing. 49 | // An empty implementation adversely affects performance during animation. 50 | - (void)drawRect:(CGRect)rect { 51 | 52 | // Drawing code 53 | CGContextRef context = UIGraphicsGetCurrentContext(); 54 | CGContextSaveGState(context); 55 | 56 | CGContextSetShadow(context, self.glowOffset, self.glowAmount); 57 | CGContextSetShadowWithColor(context, self.glowOffset, self.glowAmount, glowColorRef); 58 | 59 | CGContextRestoreGState(context); 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/MenuButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // MenuButton.h 3 | // JackFastKit 4 | // 5 | // Created by 曾 宪华 on 14-10-13. 6 | // Copyright (c) 2014年 华捷 iOS软件开发工程师 曾宪华. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class MenuItem; 12 | 13 | typedef void(^DidSelctedItemCompletedBlock)(MenuItem *menuItem); 14 | 15 | 16 | @interface MenuButton : UIView 17 | 18 | @property (nonatomic, copy) DidSelctedItemCompletedBlock didSelctedItemCompleted; 19 | 20 | - (instancetype)initWithFrame:(CGRect)frame 21 | menuItem:(MenuItem *)menuItem; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/MenuButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // MenuButton.m 3 | // JackFastKit 4 | // 5 | // Created by 曾 宪华 on 14-10-13. 6 | // Copyright (c) 2014年 华捷 iOS软件开发工程师 曾宪华. All rights reserved. 7 | // 8 | 9 | #import "MenuButton.h" 10 | #import "POP.h" 11 | 12 | // Model 13 | #import "MenuItem.h" 14 | 15 | // View 16 | #import "GlowImageView.h" 17 | 18 | @interface MenuButton () 19 | 20 | @property (nonatomic, strong) GlowImageView *iconImageView; 21 | @property (nonatomic, strong) UILabel *titleLabel; 22 | 23 | @property (nonatomic, strong) MenuItem *menuItem; 24 | 25 | @end 26 | 27 | @implementation MenuButton 28 | 29 | - (instancetype)initWithFrame:(CGRect)frame 30 | menuItem:(MenuItem *)menuItem { 31 | 32 | self = [super initWithFrame:frame]; 33 | if (self) { 34 | // Initialization code 35 | self.menuItem = menuItem; 36 | 37 | self.iconImageView = [[GlowImageView alloc] initWithFrame:CGRectMake(0, 0, menuItem.iconImage.size.width, menuItem.iconImage.size.height)]; 38 | self.iconImageView.userInteractionEnabled = NO; 39 | [self.iconImageView setImage:menuItem.iconImage forState:UIControlStateNormal]; 40 | self.iconImageView.glowColor = menuItem.glowColor; 41 | self.iconImageView.center = CGPointMake(CGRectGetMidX(self.bounds), CGRectGetMidY(self.iconImageView.bounds)); 42 | [self addSubview:self.iconImageView]; 43 | 44 | self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.iconImageView.frame), CGRectGetWidth(self.bounds), 35)]; 45 | self.titleLabel.textColor = [UIColor whiteColor]; 46 | self.titleLabel.backgroundColor = [UIColor clearColor]; 47 | self.titleLabel.font = [UIFont systemFontOfSize:14]; 48 | self.titleLabel.textAlignment = NSTextAlignmentCenter; 49 | self.titleLabel.text = menuItem.title; 50 | CGPoint center = self.titleLabel.center; 51 | center.x = CGRectGetMidX(self.bounds); 52 | self.titleLabel.center = center; 53 | [self addSubview:self.titleLabel]; 54 | } 55 | return self; 56 | } 57 | 58 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 59 | // 播放缩放动画 60 | POPSpringAnimation *scaleAnimation = [POPSpringAnimation animation]; 61 | scaleAnimation.springBounciness = 20; // value between 0-20 62 | scaleAnimation.springSpeed = 20; // value between 0-20 63 | scaleAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewScaleXY]; 64 | scaleAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(1.3, 1.3)]; 65 | [self pop_addAnimation:scaleAnimation forKey:@"scaleAnimationKey"]; 66 | } 67 | 68 | - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { 69 | [self disMissCompleted:NULL]; 70 | } 71 | 72 | - (void)disMissCompleted:(void(^)(BOOL finished))completed { 73 | POPSpringAnimation *scaleAnimation = [POPSpringAnimation animation]; 74 | scaleAnimation.springBounciness = 16; // value between 0-20 75 | scaleAnimation.springSpeed = 14; // value between 0-20 76 | scaleAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewScaleXY]; 77 | scaleAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(1.0, 1.0)]; 78 | scaleAnimation.completionBlock = ^(POPAnimation *anim, BOOL finished) { 79 | if (completed) { 80 | completed(finished); 81 | } 82 | }; 83 | [self pop_addAnimation:scaleAnimation forKey:@"scaleAnimationKey"]; 84 | } 85 | 86 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 87 | // 回调 88 | [self disMissCompleted:^(BOOL finished) { 89 | if (self.didSelctedItemCompleted) { 90 | self.didSelctedItemCompleted(self.menuItem); 91 | } 92 | }]; 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/MenuItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // MenuItem.h 3 | // JackFastKit 4 | // 5 | // Created by 曾 宪华 on 14-10-13. 6 | // Copyright (c) 2014年 华捷 iOS软件开发工程师 曾宪华. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface MenuItem : NSObject 13 | 14 | @property (nonatomic, copy) NSString *title; 15 | @property (nonatomic, strong) UIImage *iconImage; 16 | @property (nonatomic, strong) UIColor *glowColor; 17 | @property (nonatomic, assign) NSUInteger index; 18 | 19 | - (instancetype)initWithTitle:(NSString *)title 20 | iconName:(NSString *)iconName 21 | glowColor:(UIColor *)glowColor 22 | index:(NSUInteger)index; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/MenuItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // MenuItem.m 3 | // JackFastKit 4 | // 5 | // Created by 曾 宪华 on 14-10-13. 6 | // Copyright (c) 2014年 华捷 iOS软件开发工程师 曾宪华. All rights reserved. 7 | // 8 | 9 | #import "MenuItem.h" 10 | 11 | @implementation MenuItem 12 | 13 | - (instancetype)initWithTitle:(NSString *)title 14 | iconName:(NSString *)iconName 15 | glowColor:(UIColor *)glowColor 16 | index:(NSUInteger)index { 17 | self = [super init]; 18 | if (self) { 19 | self.title = title; 20 | self.iconImage = [UIImage imageNamed:iconName]; 21 | self.glowColor = glowColor; 22 | self.index = index; 23 | } 24 | return self; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/PopMenu.h: -------------------------------------------------------------------------------- 1 | // 2 | // MenuView.h 3 | // JackFastKit 4 | // 5 | // Created by 曾 宪华 on 14-10-13. 6 | // Copyright (c) 2014年 华捷 iOS软件开发工程师 曾宪华. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MenuItem.h" 11 | 12 | typedef NS_ENUM(NSInteger, PopMenuAnimationType) { 13 | kPopMenuAnimationTypeSina = 0, 14 | kPopMenuAnimationTypeNetEase = 1, 15 | }; 16 | 17 | typedef void(^DidSelectedItemBlock)(MenuItem *selectedItem); 18 | 19 | @interface PopMenu : UIView 20 | 21 | @property (nonatomic, assign) PopMenuAnimationType menuAnimationType; 22 | 23 | @property (nonatomic, assign, readonly) BOOL isShowed; 24 | 25 | @property (nonatomic, strong, readonly) NSArray *items; 26 | 27 | @property (nonatomic, copy) DidSelectedItemBlock didSelectedItemCompletion; 28 | 29 | - (instancetype)initWithFrame:(CGRect)frame 30 | items:(NSArray *)items; 31 | 32 | - (void)showMenuAtView:(UIView *)containerView; 33 | - (void)showMenuAtView:(UIView *)containerView 34 | startPoint:(CGPoint)startPoint 35 | endPoint:(CGPoint)endPoint; 36 | - (void)dismissMenu; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/XHRealTimeBlur/XHRealTimeBlur.h: -------------------------------------------------------------------------------- 1 | // 2 | // XHRealTimeBlur.h 3 | // XHRealTimeBlurExample 4 | // 5 | // Created by 曾 宪华 on 14-9-7. 6 | // Copyright (c) 2014年 曾宪华 QQ群: (142557668) QQ:543413507 Gmail:xhzengAIB@gmail.com. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | typedef void(^WillShowBlurViewBlcok)(void); 13 | typedef void(^DidShowBlurViewBlcok)(BOOL finished); 14 | 15 | typedef void(^WillDismissBlurViewBlcok)(void); 16 | typedef void(^DidDismissBlurViewBlcok)(BOOL finished); 17 | 18 | 19 | static NSString * const XHRealTimeBlurKey = @"XHRealTimeBlurKey"; 20 | 21 | static NSString * const XHRealTimeWillShowBlurViewBlcokBlcokKey = @"XHRealTimeWillShowBlurViewBlcokBlcokKey"; 22 | static NSString * const XHRealTimeDidShowBlurViewBlcokBlcokKey = @"XHRealTimeDidShowBlurViewBlcokBlcokKey"; 23 | 24 | static NSString * const XHRealTimeWillDismissBlurViewBlcokKey = @"XHRealTimeWillDismissBlurViewBlcokKey"; 25 | static NSString * const XHRealTimeDidDismissBlurViewBlcokKey = @"XHRealTimeDidDismissBlurViewBlcokKey"; 26 | 27 | typedef NS_ENUM(NSInteger, XHBlurStyle) { 28 | // 垂直梯度背景从黑色到半透明的。 29 | XHBlurStyleBlackGradient = 0, 30 | // 类似UIToolbar的半透明背景 31 | XHBlurStyleTranslucent, 32 | // 黑色半透明背景 33 | XHBlurStyleBlackTranslucent, 34 | // 纯白色 35 | XHBlurStyleWhite 36 | }; 37 | 38 | @interface XHRealTimeBlur : UIView 39 | 40 | /** 41 | * Default is XHBlurStyleTranslucent 42 | */ 43 | @property (nonatomic, assign) XHBlurStyle blurStyle; 44 | 45 | @property (nonatomic, assign) BOOL showed; 46 | 47 | // Default is 0.3 48 | @property (nonatomic, assign) NSTimeInterval showDuration; 49 | 50 | // Default is 0.3 51 | @property (nonatomic, assign) NSTimeInterval disMissDuration; 52 | 53 | /** 54 | * 是否触发点击手势,默认关闭 55 | */ 56 | @property (nonatomic, assign) BOOL hasTapGestureEnable; 57 | 58 | @property (nonatomic, copy) WillShowBlurViewBlcok willShowBlurViewcomplted; 59 | @property (nonatomic, copy) DidShowBlurViewBlcok didShowBlurViewcompleted; 60 | 61 | @property (nonatomic, copy) WillDismissBlurViewBlcok willDismissBlurViewCompleted; 62 | @property (nonatomic, copy) DidDismissBlurViewBlcok didDismissBlurViewCompleted; 63 | 64 | 65 | - (void)showBlurViewAtView:(UIView *)currentView; 66 | 67 | - (void)showBlurViewAtViewController:(UIViewController *)currentViewContrller; 68 | 69 | - (void)disMiss; 70 | 71 | @end 72 | 73 | @interface UIView (XHRealTimeBlur) 74 | 75 | @property (nonatomic, copy) WillShowBlurViewBlcok willShowBlurViewcomplted; 76 | @property (nonatomic, copy) DidShowBlurViewBlcok didShowBlurViewcompleted; 77 | 78 | 79 | @property (nonatomic, copy) WillDismissBlurViewBlcok willDismissBlurViewCompleted; 80 | @property (nonatomic, copy) DidDismissBlurViewBlcok didDismissBlurViewCompleted; 81 | 82 | - (void)showRealTimeBlurWithBlurStyle:(XHBlurStyle)blurStyle; 83 | - (void)showRealTimeBlurWithBlurStyle:(XHBlurStyle)blurStyle hasTapGestureEnable:(BOOL)hasTapGestureEnable; 84 | - (void)disMissRealTimeBlur; 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POP.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #ifndef POP_POP_H 11 | #define POP_POP_H 12 | 13 | #import "POPAnimatableProperty.h" 14 | #import "POPAnimation.h" 15 | #import "POPAnimationEvent.h" 16 | #import "POPAnimationExtras.h" 17 | #import "POPAnimationTracer.h" 18 | #import "POPAnimator.h" 19 | #import "POPBasicAnimation.h" 20 | #import "POPCustomAnimation.h" 21 | #import "POPDecayAnimation.h" 22 | #import "POPDefines.h" 23 | #import "POPGeometry.h" 24 | #import "POPPropertyAnimation.h" 25 | #import "POPSpringAnimation.h" 26 | 27 | 28 | #endif /* POP_POP_H */ 29 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPAction.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #ifndef POPACTION_H 11 | #define POPACTION_H 12 | 13 | #import 14 | #import "POPDefines.h" 15 | 16 | #ifdef __cplusplus 17 | 18 | namespace POP { 19 | 20 | /** 21 | @abstract Disables Core Animation actions using RAII. 22 | @discussion The disablement of actions is scoped to the current transaction. 23 | */ 24 | class ActionDisabler 25 | { 26 | BOOL state; 27 | 28 | public: 29 | ActionDisabler() POP_NOTHROW 30 | { 31 | state = [CATransaction disableActions]; 32 | [CATransaction setDisableActions:YES]; 33 | } 34 | 35 | ~ActionDisabler() 36 | { 37 | [CATransaction setDisableActions:state]; 38 | } 39 | }; 40 | 41 | /** 42 | @abstract Enables Core Animation actions using RAII. 43 | @discussion The enablement of actions is scoped to the current transaction. 44 | */ 45 | class ActionEnabler 46 | { 47 | BOOL state; 48 | 49 | public: 50 | ActionEnabler() POP_NOTHROW 51 | { 52 | state = [CATransaction disableActions]; 53 | [CATransaction setDisableActions:NO]; 54 | } 55 | 56 | ~ActionEnabler() 57 | { 58 | [CATransaction setDisableActions:state]; 59 | } 60 | }; 61 | 62 | } 63 | 64 | #endif /* __cplusplus */ 65 | 66 | #endif /* POPACTION_H */ 67 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPAnimatableProperty.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | @class POPMutableAnimatableProperty; 14 | 15 | /** 16 | @abstract Describes an animatable property. 17 | */ 18 | @interface POPAnimatableProperty : NSObject 19 | 20 | /** 21 | @abstract Property accessor. 22 | @param name The name of the property. 23 | @return The animatable property with that name or nil if it does not exist. 24 | @discussion Common animatable properties are included by default. Use the provided constants to reference. 25 | */ 26 | + (id)propertyWithName:(NSString *)name; 27 | 28 | /** 29 | @abstract The designated initializer. 30 | @param name The name of the property. 31 | @param block The block used to configure the property on creation. 32 | @return The animatable property with name if it exists, otherwise a newly created instance configured by block. 33 | @discussion Custom properties should use reverse-DNS naming. A newly created instance is only mutable in the scope of block. Once constructed, a property becomes immutable. 34 | */ 35 | + (id)propertyWithName:(NSString *)name initializer:(void (^)(POPMutableAnimatableProperty *prop))block; 36 | 37 | /** 38 | @abstract The name of the property. 39 | @discussion Used to uniquely identify an animatable property. 40 | */ 41 | @property (readonly, nonatomic, copy) NSString *name; 42 | 43 | /** 44 | @abstract Block used to read values from a property into an array of floats. 45 | */ 46 | @property (readonly, nonatomic, copy) void (^readBlock)(id obj, CGFloat values[]); 47 | 48 | /** 49 | @abstract Block used to write values from an array of floats into a property. 50 | */ 51 | @property (readonly, nonatomic, copy) void (^writeBlock)(id obj, const CGFloat values[]); 52 | 53 | /** 54 | @abstract The threshold value used when determining completion of dynamics simulations. 55 | */ 56 | @property (readonly, nonatomic, assign) CGFloat threshold; 57 | 58 | @end 59 | 60 | /** 61 | @abstract A mutable animatable property intended for configuration. 62 | */ 63 | @interface POPMutableAnimatableProperty : POPAnimatableProperty 64 | 65 | /** 66 | @abstract A read-write version of POPAnimatableProperty name property. 67 | */ 68 | @property (readwrite, nonatomic, copy) NSString *name; 69 | 70 | /** 71 | @abstract A read-write version of POPAnimatableProperty readBlock property. 72 | */ 73 | @property (readwrite, nonatomic, copy) void (^readBlock)(id obj, CGFloat values[]); 74 | 75 | /** 76 | @abstract A read-write version of POPAnimatableProperty writeBlock property. 77 | */ 78 | @property (readwrite, nonatomic, copy) void (^writeBlock)(id obj, const CGFloat values[]); 79 | 80 | /** 81 | @abstract A read-write version of POPAnimatableProperty threshold property. 82 | */ 83 | @property (readwrite, nonatomic, assign) CGFloat threshold; 84 | 85 | @end 86 | 87 | /** 88 | Common CALayer property names. 89 | */ 90 | extern NSString * const kPOPLayerBackgroundColor; 91 | extern NSString * const kPOPLayerBounds; 92 | extern NSString * const kPOPLayerCornerRadius; 93 | extern NSString * const kPOPLayerBorderWidth; 94 | extern NSString * const kPOPLayerBorderColor; 95 | extern NSString * const kPOPLayerOpacity; 96 | extern NSString * const kPOPLayerPosition; 97 | extern NSString * const kPOPLayerPositionX; 98 | extern NSString * const kPOPLayerPositionY; 99 | extern NSString * const kPOPLayerRotation; 100 | extern NSString * const kPOPLayerRotationX; 101 | extern NSString * const kPOPLayerRotationY; 102 | extern NSString * const kPOPLayerScaleX; 103 | extern NSString * const kPOPLayerScaleXY; 104 | extern NSString * const kPOPLayerScaleY; 105 | extern NSString * const kPOPLayerSize; 106 | extern NSString * const kPOPLayerSubscaleXY; 107 | extern NSString * const kPOPLayerSubtranslationX; 108 | extern NSString * const kPOPLayerSubtranslationXY; 109 | extern NSString * const kPOPLayerSubtranslationY; 110 | extern NSString * const kPOPLayerSubtranslationZ; 111 | extern NSString * const kPOPLayerTranslationX; 112 | extern NSString * const kPOPLayerTranslationXY; 113 | extern NSString * const kPOPLayerTranslationY; 114 | extern NSString * const kPOPLayerTranslationZ; 115 | extern NSString * const kPOPLayerZPosition; 116 | extern NSString * const kPOPLayerShadowColor; 117 | extern NSString * const kPOPLayerShadowOffset; 118 | extern NSString * const kPOPLayerShadowOpacity; 119 | extern NSString * const kPOPLayerShadowRadius; 120 | 121 | /** 122 | Common CAShapeLayer property names. 123 | */ 124 | extern NSString * const kPOPShapeLayerStrokeStart; 125 | extern NSString * const kPOPShapeLayerStrokeEnd; 126 | extern NSString * const kPOPShapeLayerStrokeColor; 127 | extern NSString * const kPOPShapeLayerFillColor; 128 | 129 | /** 130 | Common NSLayoutConstraint property names. 131 | */ 132 | extern NSString * const kPOPLayoutConstraintConstant; 133 | 134 | 135 | #if TARGET_OS_IPHONE 136 | 137 | /** 138 | Common UIView property names. 139 | */ 140 | extern NSString * const kPOPViewAlpha; 141 | extern NSString * const kPOPViewBackgroundColor; 142 | extern NSString * const kPOPViewBounds; 143 | extern NSString * const kPOPViewCenter; 144 | extern NSString * const kPOPViewFrame; 145 | extern NSString * const kPOPViewScaleX; 146 | extern NSString * const kPOPViewScaleXY; 147 | extern NSString * const kPOPViewScaleY; 148 | extern NSString * const kPOPViewSize; 149 | extern NSString * const kPOPViewTintColor; 150 | 151 | /** 152 | Common UIScrollView property names. 153 | */ 154 | extern NSString * const kPOPScrollViewContentOffset; 155 | extern NSString * const kPOPScrollViewContentSize; 156 | extern NSString * const kPOPScrollViewZoomScale; 157 | extern NSString * const kPOPScrollViewContentInset; 158 | 159 | /** 160 | Common UITableView property names. 161 | */ 162 | extern NSString * const kPOPTableViewContentOffset; 163 | extern NSString * const kPOPTableViewContentSize; 164 | 165 | /** 166 | Common UICollectionView property names. 167 | */ 168 | extern NSString * const kPOPCollectionViewContentOffset; 169 | extern NSString * const kPOPCollectionViewContentSize; 170 | 171 | /** 172 | Common UINavigationBar property names. 173 | */ 174 | extern NSString * const kPOPNavigationBarBarTintColor; 175 | 176 | /** 177 | Common UIToolbar property names. 178 | */ 179 | extern NSString * const kPOPToolbarBarTintColor; 180 | 181 | /** 182 | Common UITabBar property names. 183 | */ 184 | extern NSString * const kPOPTabBarBarTintColor; 185 | 186 | /** 187 | Common UILabel property names. 188 | */ 189 | extern NSString * const kPOPLabelTextColor; 190 | 191 | #endif 192 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPAnimation.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "POPAnimationTracer.h" 13 | #import "POPGeometry.h" 14 | 15 | @class CAMediaTimingFunction; 16 | 17 | /** 18 | @abstract The abstract animation base class. 19 | @discussion Instantiate and use one of the concrete animation subclasses. 20 | */ 21 | @interface POPAnimation : NSObject 22 | 23 | /** 24 | @abstract The name of the animation. 25 | @discussion Optional property to help identify the animation. 26 | */ 27 | @property (copy, nonatomic) NSString *name; 28 | 29 | /** 30 | @abstract The beginTime of the animation in media time. 31 | @discussion Defaults to 0 and starts immediately. 32 | */ 33 | @property (assign, nonatomic) CFTimeInterval beginTime; 34 | 35 | /** 36 | @abstract The animation delegate. 37 | @discussion See {@ref POPAnimationDelegate} for details. 38 | */ 39 | @property (weak, nonatomic) id delegate; 40 | 41 | /** 42 | @abstract The animation tracer. 43 | @discussion Returns the existing tracer, creating one if needed. Call start/stop on the tracer to toggle event collection. 44 | */ 45 | @property (readonly, nonatomic) POPAnimationTracer *tracer; 46 | 47 | /** 48 | @abstract Optional block called on animation completion. 49 | */ 50 | @property (copy, nonatomic) void (^completionBlock)(POPAnimation *anim, BOOL finished); 51 | 52 | /** 53 | @abstract Flag indicating whether animation should be removed on completion. 54 | @discussion Setting to NO can facilitate animation reuse. Defaults to YES. 55 | */ 56 | @property (assign, nonatomic) BOOL removedOnCompletion; 57 | 58 | /** 59 | @abstract Flag indicating whether animation is paused. 60 | @discussion A paused animation is excluded from the list of active animations. On initial creation, defaults to YES. On animation addition, the animation is implicity unpaused. On animation completion, the animation is implicity paused including for animations with removedOnCompletion set to NO. 61 | */ 62 | @property (assign, nonatomic, getter = isPaused) BOOL paused; 63 | 64 | /** 65 | @abstract Flag indicating whether animation autoreverses. 66 | @discussion An animation that autoreverses will have twice the duration before it is considered finished. It will animate to the toValue, stop, then animate back to the original fromValue. The delegate methods are called as follows: 67 | 68 | 1) animationDidStart: is called at the beginning, as usual, and then after each toValue is reached and the autoreverse is going to start. 69 | 2) animationDidReachToValue: is called every time the toValue is reached. The toValue is swapped with the fromValue at the end of each animation segment. This means that with autoreverses set to YES, the animationDidReachToValue: delegate method will be called a minimum of twice. 70 | 3) animationDidStop:finished: is called every time the toValue is reached, the finished argument will be NO if the autoreverse is not yet complete. 71 | */ 72 | @property (assign, nonatomic) BOOL autoreverses; 73 | 74 | /** 75 | @abstract The number of times to repeat the animation. 76 | @discussion A repeatCount of 0 or 1 means that the animation will not repeat, just like Core Animation. A repeatCount of 2 or greater means that the animation will run that many times before stopping. The delegate methods are called as follows: 77 | 78 | 1) animationDidStart: is called at the beginning of each animation repeat. 79 | 2) animationDidReachToValue: is called every time the toValue is reached. 80 | 3) animationDidStop:finished: is called every time the toValue is reached, the finished argument will be NO if the autoreverse is not yet complete. 81 | 82 | When combined with the autoreverses property, a singular animation is effectively twice as long. 83 | */ 84 | @property (assign, nonatomic) NSInteger repeatCount; 85 | 86 | /** 87 | @abstract Repeat the animation forever. 88 | @discussion This property will make the animation repeat forever. The value of the repeatCount property is undefined when this property is set. The finished parameter of the delegate callback animationDidStop:finished: will always be NO. 89 | */ 90 | @property (assign, nonatomic) BOOL repeatForever; 91 | 92 | @end 93 | 94 | /** 95 | @abstract The animation delegate. 96 | */ 97 | @protocol POPAnimationDelegate 98 | @optional 99 | 100 | /** 101 | @abstract Called on animation start. 102 | @param anim The relevant animation. 103 | */ 104 | - (void)pop_animationDidStart:(POPAnimation *)anim; 105 | 106 | /** 107 | @abstract Called when value meets or exceeds to value. 108 | @param anim The relevant animation. 109 | */ 110 | - (void)pop_animationDidReachToValue:(POPAnimation *)anim; 111 | 112 | /** 113 | @abstract Called on animation stop. 114 | @param anim The relevant animation. 115 | @param finished Flag indicating finished state. Flag is true if the animation reached completion before being removed. 116 | */ 117 | - (void)pop_animationDidStop:(POPAnimation *)anim finished:(BOOL)finished; 118 | 119 | /** 120 | @abstract Called each frame animation is applied. 121 | @param anim The relevant animation. 122 | */ 123 | - (void)pop_animationDidApply:(POPAnimation *)anim; 124 | 125 | @end 126 | 127 | 128 | @interface NSObject (POP) 129 | 130 | /** 131 | @abstract Add an animation to the reciver. 132 | @param anim The animation to add. 133 | @param key The key used to identify the animation. 134 | @discussion The 'key' may be any string such that only one animation per unique key is added per object. 135 | */ 136 | - (void)pop_addAnimation:(POPAnimation *)anim forKey:(NSString *)key; 137 | 138 | /** 139 | @abstract Remove all animations attached to the receiver. 140 | */ 141 | - (void)pop_removeAllAnimations; 142 | 143 | /** 144 | @abstract Remove any animation attached to the receiver for 'key'. 145 | @param key The key used to identify the animation. 146 | */ 147 | - (void)pop_removeAnimationForKey:(NSString *)key; 148 | 149 | /** 150 | @abstract Returns an array containing the keys of all animations currently attached to the receiver. 151 | @param The order of keys reflects the order in which animations will be applied. 152 | */ 153 | - (NSArray *)pop_animationKeys; 154 | 155 | /** 156 | @abstract Returns any animation attached to the receiver. 157 | @param key The key used to identify the animation. 158 | @returns The animation currently attached, or nil if no such animation exists. 159 | */ 160 | - (id)pop_animationForKey:(NSString *)key; 161 | 162 | @end 163 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPAnimationEvent.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | /** 13 | @abstract Enumeraton of animation event types. 14 | */ 15 | typedef NS_ENUM(NSUInteger, POPAnimationEventType) { 16 | kPOPAnimationEventPropertyRead = 0, 17 | kPOPAnimationEventPropertyWrite, 18 | kPOPAnimationEventToValueUpdate, 19 | kPOPAnimationEventFromValueUpdate, 20 | kPOPAnimationEventVelocityUpdate, 21 | kPOPAnimationEventBouncinessUpdate, 22 | kPOPAnimationEventSpeedUpdate, 23 | kPOPAnimationEventFrictionUpdate, 24 | kPOPAnimationEventMassUpdate, 25 | kPOPAnimationEventTensionUpdate, 26 | kPOPAnimationEventDidStart, 27 | kPOPAnimationEventDidStop, 28 | kPOPAnimationEventDidReachToValue, 29 | kPOPAnimationEventAutoreversed 30 | }; 31 | 32 | /** 33 | @abstract The base animation event class. 34 | */ 35 | @interface POPAnimationEvent : NSObject 36 | 37 | /** 38 | @abstract The event type. See {@ref POPAnimationEventType} for possible values. 39 | */ 40 | @property (readonly, nonatomic, assign) POPAnimationEventType type; 41 | 42 | /** 43 | @abstract The time of event. 44 | */ 45 | @property (readonly, nonatomic, assign) CFTimeInterval time; 46 | 47 | /** 48 | @abstract Optional string describing the animation at time of event. 49 | */ 50 | @property (readonly, nonatomic, copy) NSString *animationDescription; 51 | 52 | @end 53 | 54 | /** 55 | @abstract An animation event subclass for recording value and velocity. 56 | */ 57 | @interface POPAnimationValueEvent : POPAnimationEvent 58 | 59 | /** 60 | @abstract The value recorded. 61 | */ 62 | @property (readonly, nonatomic, strong) id value; 63 | 64 | /** 65 | @abstract The velocity recorded, if any. 66 | */ 67 | @property (readonly, nonatomic, strong) id velocity; 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPAnimationEvent.mm: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPAnimationEvent.h" 11 | #import "POPAnimationEventInternal.h" 12 | 13 | static NSString *stringFromType(POPAnimationEventType aType) 14 | { 15 | switch (aType) { 16 | case kPOPAnimationEventPropertyRead: 17 | return @"read"; 18 | case kPOPAnimationEventPropertyWrite: 19 | return @"write"; 20 | case kPOPAnimationEventToValueUpdate: 21 | return @"toValue"; 22 | case kPOPAnimationEventFromValueUpdate: 23 | return @"fromValue"; 24 | case kPOPAnimationEventVelocityUpdate: 25 | return @"velocity"; 26 | case kPOPAnimationEventSpeedUpdate: 27 | return @"speed"; 28 | case kPOPAnimationEventBouncinessUpdate: 29 | return @"bounciness"; 30 | case kPOPAnimationEventFrictionUpdate: 31 | return @"friction"; 32 | case kPOPAnimationEventMassUpdate: 33 | return @"mass"; 34 | case kPOPAnimationEventTensionUpdate: 35 | return @"tension"; 36 | case kPOPAnimationEventDidStart: 37 | return @"didStart"; 38 | case kPOPAnimationEventDidStop: 39 | return @"didStop"; 40 | case kPOPAnimationEventDidReachToValue: 41 | return @"didReachToValue"; 42 | case kPOPAnimationEventAutoreversed: 43 | return @"autoreversed"; 44 | default: 45 | return nil; 46 | } 47 | } 48 | 49 | @implementation POPAnimationEvent 50 | @synthesize type = _type; 51 | @synthesize time = _time; 52 | @synthesize animationDescription = _animationDescription; 53 | 54 | - (instancetype)initWithType:(POPAnimationEventType)aType time:(CFTimeInterval)aTime 55 | { 56 | self = [super init]; 57 | if (nil != self) { 58 | _type = aType; 59 | _time = aTime; 60 | } 61 | return self; 62 | } 63 | 64 | - (NSString *)description 65 | { 66 | NSMutableString *s = [NSMutableString stringWithFormat:@""]; 69 | return s; 70 | } 71 | 72 | // subclass override 73 | - (void)_appendDescription:(NSMutableString *)s 74 | { 75 | if (0 != _animationDescription.length) { 76 | [s appendFormat:@"; animation = %@", _animationDescription]; 77 | } 78 | } 79 | 80 | @end 81 | 82 | @implementation POPAnimationValueEvent 83 | @synthesize value = _value; 84 | @synthesize velocity = _velocity; 85 | 86 | - (instancetype)initWithType:(POPAnimationEventType)aType time:(CFTimeInterval)aTime value:(id)aValue 87 | { 88 | self = [self initWithType:aType time:aTime]; 89 | if (nil != self) { 90 | _value = aValue; 91 | } 92 | return self; 93 | } 94 | 95 | - (void)_appendDescription:(NSMutableString *)s 96 | { 97 | [super _appendDescription:s]; 98 | 99 | if (nil != _value) { 100 | [s appendFormat:@"; value = %@", _value]; 101 | } 102 | 103 | if (nil != _velocity) { 104 | [s appendFormat:@"; velocity = %@", _velocity]; 105 | } 106 | } 107 | 108 | @end 109 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPAnimationEventInternal.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "POPAnimationEvent.h" 13 | 14 | @interface POPAnimationEvent () 15 | 16 | /** 17 | @abstract Default initializer. 18 | */ 19 | - (instancetype)initWithType:(POPAnimationEventType)type time:(CFTimeInterval)time; 20 | 21 | /** 22 | @abstract Readwrite redefinition of public property. 23 | */ 24 | @property (readwrite, nonatomic, copy) NSString *animationDescription; 25 | 26 | @end 27 | 28 | @interface POPAnimationValueEvent () 29 | 30 | /** 31 | @abstract Default initializer. 32 | */ 33 | - (instancetype)initWithType:(POPAnimationEventType)type time:(CFTimeInterval)time value:(id)value; 34 | 35 | /** 36 | @abstract Readwrite redefinition of public property. 37 | */ 38 | @property (readwrite, nonatomic, strong) id velocity; 39 | 40 | @end 41 | 42 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPAnimationExtras.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "POPDefines.h" 13 | #import "POPSpringAnimation.h" 14 | 15 | /** 16 | @abstract The current drag coefficient. 17 | @discussion A value greater than 1.0 indicates Simulator slow-motion animations are enabled. Defaults to 1.0. 18 | */ 19 | extern CGFloat POPAnimationDragCoefficient(); 20 | 21 | @interface CAAnimation (POPAnimationExtras) 22 | 23 | /** 24 | @abstract Apply the current drag coefficient to animation speed. 25 | @discussion Convenience utility to respect Simulator slow-motion animation settings. 26 | */ 27 | - (void)pop_applyDragCoefficient; 28 | 29 | @end 30 | 31 | @interface POPSpringAnimation (POPAnimationExtras) 32 | 33 | /** 34 | @abstract Converts from spring bounciness and speed to tension, friction and mass dynamics values. 35 | */ 36 | + (void)convertBounciness:(CGFloat)bounciness speed:(CGFloat)speed toTension:(CGFloat *)outTension friction:(CGFloat *)outFriction mass:(CGFloat *)outMass; 37 | 38 | /** 39 | @abstract Converts from dynamics tension, friction and mass to spring bounciness and speed values. 40 | */ 41 | + (void)convertTension:(CGFloat)tension friction:(CGFloat)friction toBounciness:(CGFloat *)outBounciness speed:(CGFloat *)outSpeed; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPAnimationExtras.mm: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPAnimationExtras.h" 11 | 12 | #import "POPAnimationPrivate.h" 13 | #import "POPMath.h" 14 | 15 | #if TARGET_OS_IPHONE 16 | #import 17 | #endif 18 | 19 | #if TARGET_IPHONE_SIMULATOR 20 | UIKIT_EXTERN CGFloat UIAnimationDragCoefficient(); // UIKit private drag coeffient, use judiciously 21 | #endif 22 | 23 | CGFloat POPAnimationDragCoefficient() 24 | { 25 | #if TARGET_IPHONE_SIMULATOR 26 | return UIAnimationDragCoefficient(); 27 | #else 28 | return 1.0; 29 | #endif 30 | } 31 | 32 | @implementation CAAnimation (POPAnimationExtras) 33 | 34 | - (void)pop_applyDragCoefficient 35 | { 36 | CGFloat k = POPAnimationDragCoefficient(); 37 | if (k != 0 && k != 1) 38 | self.speed = 1 / k; 39 | } 40 | 41 | @end 42 | 43 | @implementation POPSpringAnimation (POPAnimationExtras) 44 | 45 | static const CGFloat POPBouncy3NormalizationRange = 20.0; 46 | static const CGFloat POPBouncy3NormalizationScale = 1.7; 47 | static const CGFloat POPBouncy3BouncinessNormalizedMin = 0.0; 48 | static const CGFloat POPBouncy3BouncinessNormalizedMax = 0.8; 49 | static const CGFloat POPBouncy3SpeedNormalizedMin = 0.5; 50 | static const CGFloat POPBouncy3SpeedNormalizedMax = 200; 51 | static const CGFloat POPBouncy3FrictionInterpolationMax = 0.01; 52 | 53 | + (void)convertBounciness:(CGFloat)bounciness speed:(CGFloat)speed toTension:(CGFloat *)outTension friction:(CGFloat *)outFriction mass:(CGFloat *)outMass 54 | { 55 | double b = POPNormalize(bounciness / POPBouncy3NormalizationScale, 0, POPBouncy3NormalizationRange); 56 | b = POPProjectNormal(b, POPBouncy3BouncinessNormalizedMin, POPBouncy3BouncinessNormalizedMax); 57 | 58 | double s = POPNormalize(speed / POPBouncy3NormalizationScale, 0, POPBouncy3NormalizationRange); 59 | 60 | CGFloat tension = POPProjectNormal(s, POPBouncy3SpeedNormalizedMin, POPBouncy3SpeedNormalizedMax); 61 | CGFloat friction = POPQuadraticOutInterpolation(b, POPBouncy3NoBounce(tension), POPBouncy3FrictionInterpolationMax); 62 | 63 | tension = POP_ANIMATION_TENSION_FOR_QC_TENSION(tension); 64 | friction = POP_ANIMATION_FRICTION_FOR_QC_FRICTION(friction); 65 | 66 | if (outTension) { 67 | *outTension = tension; 68 | } 69 | 70 | if (outFriction) { 71 | *outFriction = friction; 72 | } 73 | 74 | if (outMass) { 75 | *outMass = 1.0; 76 | } 77 | } 78 | 79 | + (void)convertTension:(CGFloat)tension friction:(CGFloat)friction toBounciness:(CGFloat *)outBounciness speed:(CGFloat *)outSpeed 80 | { 81 | // Convert to QC values, in which our calculations are done. 82 | CGFloat qcFriction = QC_FRICTION_FOR_POP_ANIMATION_FRICTION(friction); 83 | CGFloat qcTension = QC_TENSION_FOR_POP_ANIMATION_TENSION(tension); 84 | 85 | // Friction is a function of bounciness and tension, according to the following: 86 | // friction = POPQuadraticOutInterpolation(b, POPBouncy3NoBounce(tension), POPBouncy3FrictionInterpolationMax); 87 | // Solve for bounciness, given a tension and friction. 88 | 89 | CGFloat nobounceTension = POPBouncy3NoBounce(qcTension); 90 | CGFloat bounciness1, bounciness2; 91 | 92 | POPQuadraticSolve((nobounceTension - POPBouncy3FrictionInterpolationMax), // a 93 | 2 * (POPBouncy3FrictionInterpolationMax - nobounceTension), // b 94 | (nobounceTension - qcFriction), // c 95 | bounciness1, // x1 96 | bounciness2); // x2 97 | 98 | 99 | // Choose the quadratic solution within the normalized bounciness range 100 | CGFloat projectedNormalizedBounciness = (bounciness2 < POPBouncy3BouncinessNormalizedMax) ? bounciness2 : bounciness1; 101 | CGFloat projectedNormalizedSpeed = qcTension; 102 | 103 | // Reverse projection + normalization 104 | CGFloat bounciness = ((POPBouncy3NormalizationRange * POPBouncy3NormalizationScale) / (POPBouncy3BouncinessNormalizedMax - POPBouncy3BouncinessNormalizedMin)) * (projectedNormalizedBounciness - POPBouncy3BouncinessNormalizedMin); 105 | CGFloat speed = ((POPBouncy3NormalizationRange * POPBouncy3NormalizationScale) / (POPBouncy3SpeedNormalizedMax - POPBouncy3SpeedNormalizedMin)) * (projectedNormalizedSpeed - POPBouncy3SpeedNormalizedMin); 106 | 107 | // Write back results 108 | if (outBounciness) { 109 | *outBounciness = bounciness; 110 | } 111 | 112 | if (outSpeed) { 113 | *outSpeed = speed; 114 | } 115 | } 116 | 117 | @end 118 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPAnimationPrivate.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPAnimation.h" 11 | 12 | #define POP_ANIMATION_FRICTION_FOR_QC_FRICTION(qcFriction) (25.0 + (((qcFriction - 8.0) / 2.0) * (25.0 - 19.0))) 13 | #define POP_ANIMATION_TENSION_FOR_QC_TENSION(qcTension) (194.0 + (((qcTension - 30.0) / 50.0) * (375.0 - 194.0))) 14 | 15 | #define QC_FRICTION_FOR_POP_ANIMATION_FRICTION(fbFriction) (8.0 + 2.0 * ((fbFriction - 25.0)/(25.0 - 19.0))) 16 | #define QC_TENSION_FOR_POP_ANIMATION_TENSION(fbTension) (30.0 + 50.0 * ((fbTension - 194.0)/(375.0 - 194.0))) 17 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPAnimationRuntime.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import 13 | 14 | #import "POPVector.h" 15 | 16 | enum POPValueType 17 | { 18 | kPOPValueUnknown = 0, 19 | kPOPValueInteger, 20 | kPOPValueFloat, 21 | kPOPValuePoint, 22 | kPOPValueSize, 23 | kPOPValueRect, 24 | kPOPValueEdgeInsets, 25 | kPOPValueAffineTransform, 26 | kPOPValueTransform, 27 | kPOPValueRange, 28 | kPOPValueColor, 29 | }; 30 | 31 | using namespace POP; 32 | 33 | /** 34 | Returns value type based on objc type description, given list of supported value types and length. 35 | */ 36 | extern POPValueType POPSelectValueType(const char *objctype, const POPValueType *types, size_t length); 37 | 38 | /** 39 | Returns value type based on objc object, given a list of supported value types and length. 40 | */ 41 | extern POPValueType POPSelectValueType(id obj, const POPValueType *types, size_t length); 42 | 43 | /** 44 | Array of all value types. 45 | */ 46 | extern const POPValueType kPOPAnimatableAllTypes[10]; 47 | 48 | /** 49 | Array of all value types supported for animation. 50 | */ 51 | extern const POPValueType kPOPAnimatableSupportTypes[8]; 52 | 53 | /** 54 | Returns a string description of a value type. 55 | */ 56 | extern NSString *POPValueTypeToString(POPValueType t); 57 | 58 | /** 59 | Returns a mutable dictionary of weak pointer keys to weak pointer values. 60 | */ 61 | extern CFMutableDictionaryRef POPDictionaryCreateMutableWeakPointerToWeakPointer(NSUInteger capacity) CF_RETURNS_RETAINED; 62 | 63 | /** 64 | Returns a mutable dictionary of weak pointer keys to weak pointer values. 65 | */ 66 | extern CFMutableDictionaryRef POPDictionaryCreateMutableWeakPointerToStrongObject(NSUInteger capacity) CF_RETURNS_RETAINED; 67 | 68 | /** 69 | Box a vector. 70 | */ 71 | extern id POPBox(VectorConstRef vec, POPValueType type, bool force = false); 72 | 73 | /** 74 | Unbox a vector. 75 | */ 76 | extern VectorRef POPUnbox(id value, POPValueType &type, NSUInteger &count, bool validate); 77 | 78 | /** 79 | Read/write block typedefs for convenience. 80 | */ 81 | typedef void(^pop_animatable_read_block)(id obj, CGFloat *value); 82 | typedef void(^pop_animatable_write_block)(id obj, const CGFloat *value); 83 | 84 | /** 85 | Read object value and return a Vector4r. 86 | */ 87 | NS_INLINE Vector4r read_values(pop_animatable_read_block read, id obj, size_t count) 88 | { 89 | Vector4r vec = Vector4r::Zero(); 90 | if (0 == count) 91 | return vec; 92 | 93 | read(obj, vec.data()); 94 | 95 | return vec; 96 | } 97 | 98 | NS_INLINE NSString *POPStringFromBOOL(BOOL value) 99 | { 100 | return value ? @"YES" : @"NO"; 101 | } 102 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPAnimationTracer.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "POPAnimationEvent.h" 13 | 14 | @class POPAnimation; 15 | 16 | /** 17 | @abstract Tracer of animation events to fasciliate unit testing & debugging. 18 | */ 19 | @interface POPAnimationTracer : NSObject 20 | 21 | /** 22 | @abstract Start recording events. 23 | */ 24 | - (void)start; 25 | 26 | /** 27 | @abstract Stop recording events. 28 | */ 29 | - (void)stop; 30 | 31 | /** 32 | @abstract Resets any recoded events. Continues recording events if already started. 33 | */ 34 | - (void)reset; 35 | 36 | /** 37 | @abstract Property representing all recorded events. 38 | @discussion Events are returned in order of occurence. 39 | */ 40 | @property (nonatomic, assign, readonly) NSArray *allEvents; 41 | 42 | /** 43 | @abstract Property representing all recorded write events for convenience. 44 | @discussion Events are returned in order of occurence. 45 | */ 46 | @property (nonatomic, assign, readonly) NSArray *writeEvents; 47 | 48 | /** 49 | @abstract Queries for events of specified type. 50 | @param type The type of event to return. 51 | @returns An array of events of specified type in order of occurence. 52 | */ 53 | - (NSArray *)eventsWithType:(POPAnimationEventType)type; 54 | 55 | /** 56 | @abstract Property indicating whether tracer should automatically log events and reset collection on animation completion. 57 | */ 58 | @property (nonatomic, assign) BOOL shouldLogAndResetOnCompletion; 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPAnimationTracer.mm: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPAnimationTracer.h" 11 | 12 | #import 13 | 14 | #import "POPAnimationEventInternal.h" 15 | #import "POPAnimationInternal.h" 16 | #import "POPSpringAnimation.h" 17 | 18 | @implementation POPAnimationTracer 19 | { 20 | __weak POPAnimation *_animation; 21 | POPAnimationState *_animationState; 22 | NSMutableArray *_events; 23 | BOOL _animationHasVelocity; 24 | } 25 | @synthesize shouldLogAndResetOnCompletion = _shouldLogAndResetOnCompletion; 26 | 27 | static POPAnimationEvent *create_event(POPAnimationTracer *self, POPAnimationEventType type, id value = nil, bool recordAnimation = false) 28 | { 29 | bool useLocalTime = 0 != self->_animationState->startTime; 30 | CFTimeInterval time = useLocalTime 31 | ? self->_animationState->lastTime - self->_animationState->startTime 32 | : self->_animationState->lastTime; 33 | 34 | POPAnimationEvent *event; 35 | 36 | if (!value) { 37 | event = [[POPAnimationEvent alloc] initWithType:type time:time]; 38 | } else { 39 | event = [[POPAnimationValueEvent alloc] initWithType:type time:time value:value]; 40 | if (self->_animationHasVelocity) { 41 | [(POPAnimationValueEvent *)event setVelocity:[(POPSpringAnimation *)self->_animation velocity]]; 42 | } 43 | } 44 | 45 | if (recordAnimation) { 46 | event.animationDescription = [self->_animation description]; 47 | } 48 | 49 | return event; 50 | } 51 | 52 | - (id)initWithAnimation:(POPAnimation *)anAnim 53 | { 54 | self = [super init]; 55 | if (nil != self) { 56 | _animation = anAnim; 57 | _animationState = POPAnimationGetState(anAnim); 58 | _events = [[NSMutableArray alloc] initWithCapacity:50]; 59 | _animationHasVelocity = [anAnim respondsToSelector:@selector(velocity)]; 60 | } 61 | return self; 62 | } 63 | 64 | - (void)readPropertyValue:(id)aValue 65 | { 66 | POPAnimationEvent *event = create_event(self, kPOPAnimationEventPropertyRead, aValue); 67 | [_events addObject:event]; 68 | } 69 | 70 | - (void)writePropertyValue:(id)aValue 71 | { 72 | POPAnimationEvent *event = create_event(self, kPOPAnimationEventPropertyWrite, aValue); 73 | [_events addObject:event]; 74 | } 75 | 76 | - (void)updateToValue:(id)aValue 77 | { 78 | POPAnimationEvent *event = create_event(self, kPOPAnimationEventToValueUpdate, aValue); 79 | [_events addObject:event]; 80 | } 81 | 82 | - (void)updateFromValue:(id)aValue 83 | { 84 | POPAnimationEvent *event = create_event(self, kPOPAnimationEventFromValueUpdate, aValue); 85 | [_events addObject:event]; 86 | } 87 | 88 | - (void)updateVelocity:(id)aValue 89 | { 90 | POPAnimationEvent *event = create_event(self, kPOPAnimationEventVelocityUpdate, aValue); 91 | [_events addObject:event]; 92 | } 93 | 94 | - (void)updateSpeed:(float)aFloat 95 | { 96 | POPAnimationEvent *event = create_event(self, kPOPAnimationEventSpeedUpdate, @(aFloat)); 97 | [_events addObject:event]; 98 | } 99 | 100 | - (void)updateBounciness:(float)aFloat 101 | { 102 | POPAnimationEvent *event = create_event(self, kPOPAnimationEventBouncinessUpdate, @(aFloat)); 103 | [_events addObject:event]; 104 | } 105 | 106 | - (void)updateFriction:(float)aFloat 107 | { 108 | POPAnimationEvent *event = create_event(self, kPOPAnimationEventFrictionUpdate, @(aFloat)); 109 | [_events addObject:event]; 110 | } 111 | 112 | - (void)updateMass:(float)aFloat 113 | { 114 | POPAnimationEvent *event = create_event(self, kPOPAnimationEventMassUpdate, @(aFloat)); 115 | [_events addObject:event]; 116 | } 117 | 118 | - (void)updateTension:(float)aFloat 119 | { 120 | POPAnimationEvent *event = create_event(self, kPOPAnimationEventTensionUpdate, @(aFloat)); 121 | [_events addObject:event]; 122 | } 123 | 124 | - (void)didStart 125 | { 126 | POPAnimationEvent *event = create_event(self, kPOPAnimationEventDidStart, nil, true); 127 | [_events addObject:event]; 128 | } 129 | 130 | - (void)didStop:(BOOL)finished 131 | { 132 | POPAnimationEvent *event = create_event(self, kPOPAnimationEventDidStop, @(finished), true); 133 | [_events addObject:event]; 134 | 135 | if (_shouldLogAndResetOnCompletion) { 136 | NSLog(@"events:%@", self.allEvents); 137 | [self reset]; 138 | } 139 | } 140 | 141 | - (void)didReachToValue:(id)aValue 142 | { 143 | POPAnimationEvent *event = create_event(self, kPOPAnimationEventDidReachToValue, aValue); 144 | [_events addObject:event]; 145 | } 146 | 147 | - (void)autoreversed 148 | { 149 | POPAnimationEvent *event = create_event(self, kPOPAnimationEventAutoreversed); 150 | [_events addObject:event]; 151 | } 152 | 153 | - (void)start 154 | { 155 | POPAnimationState *s = POPAnimationGetState(_animation); 156 | s->tracing = true; 157 | } 158 | 159 | - (void)stop 160 | { 161 | POPAnimationState *s = POPAnimationGetState(_animation); 162 | s->tracing = false; 163 | } 164 | 165 | - (void)reset 166 | { 167 | [_events removeAllObjects]; 168 | } 169 | 170 | - (NSArray *)allEvents 171 | { 172 | return [_events copy]; 173 | } 174 | 175 | - (NSArray *)writeEvents 176 | { 177 | return [self eventsWithType:kPOPAnimationEventPropertyWrite]; 178 | } 179 | 180 | - (NSArray *)eventsWithType:(POPAnimationEventType)aType 181 | { 182 | NSMutableArray *array = [NSMutableArray array]; 183 | for (POPAnimationEvent *event in _events) { 184 | if (aType == event.type) { 185 | [array addObject:event]; 186 | } 187 | } 188 | return array; 189 | } 190 | 191 | @end 192 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPAnimationTracerInternal.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "POPAnimationTracer.h" 13 | 14 | @interface POPAnimationTracer (Internal) 15 | 16 | /** 17 | @abstract Designated initalizer. Pass the animation being traced. 18 | */ 19 | - (instancetype)initWithAnimation:(POPAnimation *)anAnim; 20 | 21 | /** 22 | @abstract Records read value. 23 | */ 24 | - (void)readPropertyValue:(id)aValue; 25 | 26 | /** 27 | @abstract Records write value. 28 | */ 29 | - (void)writePropertyValue:(id)aValue; 30 | 31 | /** 32 | Records to value update. 33 | */ 34 | - (void)updateToValue:(id)aValue; 35 | 36 | /** 37 | @abstract Records from value update. 38 | */ 39 | - (void)updateFromValue:(id)aValue; 40 | 41 | /** 42 | @abstract Records from value update. 43 | */ 44 | - (void)updateVelocity:(id)aValue; 45 | 46 | /** 47 | @abstract Records bounciness update. 48 | */ 49 | - (void)updateBounciness:(float)aFloat; 50 | 51 | /** 52 | @abstract Records speed update. 53 | */ 54 | - (void)updateSpeed:(float)aFloat; 55 | 56 | /** 57 | @abstract Records friction update. 58 | */ 59 | - (void)updateFriction:(float)aFloat; 60 | 61 | /** 62 | @abstract Records mass update. 63 | */ 64 | - (void)updateMass:(float)aFloat; 65 | 66 | /** 67 | @abstract Records tension update. 68 | */ 69 | - (void)updateTension:(float)aFloat; 70 | 71 | /** 72 | @abstract Records did add. 73 | */ 74 | - (void)didAdd; 75 | 76 | /** 77 | @abstract Records did start. 78 | */ 79 | - (void)didStart; 80 | 81 | /** 82 | @abstract Records did stop. 83 | */ 84 | - (void)didStop:(BOOL)finished; 85 | 86 | /** 87 | @abstract Records did reach to value. 88 | */ 89 | - (void)didReachToValue:(id)aValue; 90 | 91 | /** 92 | @abstract Records when an autoreverse animation takes place. 93 | */ 94 | - (void)autoreversed; 95 | 96 | @end 97 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPAnimator.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @protocol POPAnimatorDelegate; 13 | 14 | /** 15 | @abstract The animator class renders animations. 16 | */ 17 | @interface POPAnimator : NSObject 18 | 19 | /** 20 | @abstract The shared animator instance. 21 | @discussion Consumers should generally use the shared instance in lieu of creating new instances. 22 | */ 23 | + (instancetype)sharedAnimator; 24 | 25 | /** 26 | @abstract The optional animator delegate. 27 | */ 28 | @property (weak, nonatomic) id delegate; 29 | 30 | @end 31 | 32 | /** 33 | @abstract The animator delegate. 34 | */ 35 | @protocol POPAnimatorDelegate 36 | 37 | /** 38 | @abstract Called on each frame before animation application. 39 | */ 40 | - (void)animatorWillAnimate:(POPAnimator *)animator; 41 | 42 | /** 43 | @abstract Called on each frame after animation application. 44 | */ 45 | - (void)animatorDidAnimate:(POPAnimator *)animator; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPAnimatorPrivate.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPAnimator.h" 11 | #import 12 | 13 | @class POPAnimation; 14 | 15 | @protocol POPAnimatorObserving 16 | @required 17 | 18 | /** 19 | @abstract Called on each observer after animator has advanced. Core Animation actions are disabled by default. 20 | */ 21 | - (void)animatorDidAnimate:(POPAnimator *)animator; 22 | 23 | @end 24 | 25 | @interface POPAnimator () 26 | 27 | #if !TARGET_OS_IPHONE 28 | /** 29 | Determines whether or not to use a high priority background thread for animation updates. Using a background thread can result in faster, more responsive updates, but may be less compatible. Defaults to YES. 30 | */ 31 | + (BOOL)disableBackgroundThread; 32 | + (void)setDisableBackgroundThread:(BOOL)flag; 33 | #endif 34 | 35 | /** 36 | Used for externally driven animator instances. 37 | */ 38 | @property (assign, nonatomic) BOOL disableDisplayLink; 39 | 40 | /** 41 | Time used when starting animations. Defaults to 0 meaning current media time is used. Exposed for unit testing. 42 | */ 43 | @property (assign, nonatomic) double beginTime; 44 | 45 | /** 46 | Exposed for unit testing. 47 | */ 48 | - (void)renderTime:(double)time; 49 | 50 | /** 51 | Funnel methods for category additions. 52 | */ 53 | - (void)addAnimation:(POPAnimation *)anim forObject:(id)obj key:(NSString *)key; 54 | - (void)removeAllAnimationsForObject:(id)obj; 55 | - (void)removeAnimationForObject:(id)obj key:(NSString *)key; 56 | - (NSArray *)animationKeysForObject:(id)obj; 57 | - (POPAnimation *)animationForObject:(id)obj key:(NSString *)key; 58 | 59 | /** 60 | @abstract Add an animator observer. Observer will be notified of each subsequent animator advance until removal. 61 | */ 62 | - (void)addObserver:(id)observer; 63 | 64 | /** 65 | @abstract Remove an animator observer. 66 | */ 67 | - (void)removeObserver:(id)observer; 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPBasicAnimation.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPPropertyAnimation.h" 11 | 12 | /** 13 | @abstract A concrete basic animation class. 14 | @discussion Animation is achieved through interpolation. 15 | */ 16 | @interface POPBasicAnimation : POPPropertyAnimation 17 | 18 | /** 19 | @abstract The designated initializer. 20 | @returns An instance of a basic animation. 21 | */ 22 | + (instancetype)animation; 23 | 24 | /** 25 | @abstract Convenience initializer that returns an animation with animatable property of name. 26 | @param name The name of the animatable property. 27 | @returns An instance of a basic animation configured with specified animatable property. 28 | */ 29 | + (instancetype)animationWithPropertyNamed:(NSString *)name; 30 | 31 | /** 32 | @abstract Convenience constructor. 33 | @returns Returns a basic animation with kCAMediaTimingFunctionDefault timing function. 34 | */ 35 | + (instancetype)defaultAnimation; 36 | 37 | /** 38 | @abstract Convenience constructor. 39 | @returns Returns a basic animation with kCAMediaTimingFunctionLinear timing function. 40 | */ 41 | + (instancetype)linearAnimation; 42 | 43 | /** 44 | @abstract Convenience constructor. 45 | @returns Returns a basic animation with kCAMediaTimingFunctionEaseIn timing function. 46 | */ 47 | + (instancetype)easeInAnimation; 48 | 49 | /** 50 | @abstract Convenience constructor. 51 | @returns Returns a basic animation with kCAMediaTimingFunctionEaseOut timing function. 52 | */ 53 | + (instancetype)easeOutAnimation; 54 | 55 | /** 56 | @abstract Convenience constructor. 57 | @returns Returns a basic animation with kCAMediaTimingFunctionEaseInEaseOut timing function. 58 | */ 59 | + (instancetype)easeInEaseOutAnimation; 60 | 61 | /** 62 | @abstract The duration in seconds. Defaults to 0.4. 63 | */ 64 | @property (assign, nonatomic) CFTimeInterval duration; 65 | 66 | /** 67 | @abstract A timing function defining the pacing of the animation. Defaults to nil indicating pacing according to kCAMediaTimingFunctionDefault. 68 | */ 69 | @property (strong, nonatomic) CAMediaTimingFunction *timingFunction; 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPBasicAnimation.mm: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPBasicAnimationInternal.h" 11 | 12 | @implementation POPBasicAnimation 13 | 14 | #undef __state 15 | #define __state ((POPBasicAnimationState *)_state) 16 | 17 | #pragma mark - Lifecycle 18 | 19 | + (instancetype)animation 20 | { 21 | return [[self alloc] init]; 22 | } 23 | 24 | + (instancetype)animationWithPropertyNamed:(NSString *)aName 25 | { 26 | POPBasicAnimation *anim = [self animation]; 27 | anim.property = [POPAnimatableProperty propertyWithName:aName]; 28 | return anim; 29 | } 30 | 31 | - (void)_initState 32 | { 33 | _state = new POPBasicAnimationState(self); 34 | } 35 | 36 | + (instancetype)linearAnimation 37 | { 38 | POPBasicAnimation *anim = [self animation]; 39 | anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; 40 | return anim; 41 | } 42 | 43 | + (instancetype)easeInAnimation 44 | { 45 | POPBasicAnimation *anim = [self animation]; 46 | anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; 47 | return anim; 48 | } 49 | 50 | + (instancetype)easeOutAnimation 51 | { 52 | POPBasicAnimation *anim = [self animation]; 53 | anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; 54 | return anim; 55 | } 56 | 57 | + (instancetype)easeInEaseOutAnimation 58 | { 59 | POPBasicAnimation *anim = [self animation]; 60 | anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 61 | return anim; 62 | } 63 | 64 | + (instancetype)defaultAnimation 65 | { 66 | POPBasicAnimation *anim = [self animation]; 67 | anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]; 68 | return anim; 69 | } 70 | 71 | - (id)init 72 | { 73 | return [self _init]; 74 | } 75 | 76 | #pragma mark - Properties 77 | 78 | DEFINE_RW_PROPERTY(POPBasicAnimationState, duration, setDuration:, CFTimeInterval); 79 | DEFINE_RW_PROPERTY_OBJ(POPBasicAnimationState, timingFunction, setTimingFunction:, CAMediaTimingFunction*, __state->updatedTimingFunction();); 80 | 81 | #pragma mark - Utility 82 | 83 | - (void)_appendDescription:(NSMutableString *)s debug:(BOOL)debug 84 | { 85 | [super _appendDescription:s debug:debug]; 86 | if (__state->duration) 87 | [s appendFormat:@"; duration = %f", __state->duration]; 88 | } 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPBasicAnimationInternal.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPBasicAnimation.h" 11 | #import "POPPropertyAnimationInternal.h" 12 | 13 | // default animation duration 14 | static CGFloat const kPOPAnimationDurationDefault = 0.4; 15 | 16 | // progress threshold for computing done 17 | static CGFloat const kPOPProgressThreshold = 1e-6; 18 | 19 | static void interpolate(POPValueType valueType, NSUInteger count, const CGFloat *fromVec, const CGFloat *toVec, CGFloat *outVec, CGFloat p) 20 | { 21 | switch (valueType) { 22 | case kPOPValueInteger: 23 | case kPOPValueFloat: 24 | case kPOPValuePoint: 25 | case kPOPValueSize: 26 | case kPOPValueRect: 27 | case kPOPValueEdgeInsets: 28 | case kPOPValueColor: 29 | POPInterpolateVector(count, outVec, fromVec, toVec, p); 30 | break; 31 | default: 32 | NSCAssert(false, @"unhandled type %d", valueType); 33 | break; 34 | } 35 | } 36 | 37 | struct _POPBasicAnimationState : _POPPropertyAnimationState 38 | { 39 | CAMediaTimingFunction *timingFunction; 40 | double timingControlPoints[4]; 41 | CFTimeInterval duration; 42 | CFTimeInterval timeProgress; 43 | 44 | _POPBasicAnimationState(id __unsafe_unretained anim) : _POPPropertyAnimationState(anim), 45 | timingFunction(nil), 46 | timingControlPoints{0.}, 47 | duration(kPOPAnimationDurationDefault), 48 | timeProgress(0.) 49 | { 50 | type = kPOPAnimationBasic; 51 | } 52 | 53 | bool isDone() { 54 | if (_POPPropertyAnimationState::isDone()) { 55 | return true; 56 | } 57 | return timeProgress + kPOPProgressThreshold >= 1.; 58 | } 59 | 60 | void updatedTimingFunction() 61 | { 62 | float vec[4] = {0.}; 63 | [timingFunction getControlPointAtIndex:1 values:&vec[0]]; 64 | [timingFunction getControlPointAtIndex:2 values:&vec[2]]; 65 | for (NSUInteger idx = 0; idx < POP_ARRAY_COUNT(vec); idx++) { 66 | timingControlPoints[idx] = vec[idx]; 67 | } 68 | } 69 | 70 | bool advance(CFTimeInterval time, CFTimeInterval dt, id obj) { 71 | // default timing function 72 | if (!timingFunction) { 73 | ((POPBasicAnimation *)self).timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]; 74 | } 75 | 76 | // solve for normalized time, aka progresss [0, 1] 77 | CGFloat p = 1.0f; 78 | if (duration > 0.0f) { 79 | // cap local time to duration 80 | CFTimeInterval t = MIN(time - startTime, duration) / duration; 81 | p = POPTimingFunctionSolve(timingControlPoints, t, SOLVE_EPS(duration)); 82 | timeProgress = t; 83 | } else { 84 | timeProgress = 1.; 85 | } 86 | 87 | // interpolate and advance 88 | interpolate(valueType, valueCount, fromVec->data(), toVec->data(), currentVec->data(), p); 89 | progress = p; 90 | clampCurrentValue(); 91 | 92 | return true; 93 | } 94 | }; 95 | 96 | typedef struct _POPBasicAnimationState POPBasicAnimationState; 97 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPCGUtils.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #if TARGET_OS_IPHONE 12 | #import 13 | #endif 14 | #import "POPDefines.h" 15 | 16 | #if TARGET_OS_IPHONE 17 | @class UIColor; 18 | #endif 19 | 20 | POP_EXTERN_C_BEGIN 21 | 22 | NS_INLINE CGPoint values_to_point(const CGFloat values[]) 23 | { 24 | return CGPointMake(values[0], values[1]); 25 | } 26 | 27 | NS_INLINE CGSize values_to_size(const CGFloat values[]) 28 | { 29 | return CGSizeMake(values[0], values[1]); 30 | } 31 | 32 | NS_INLINE CGRect values_to_rect(const CGFloat values[]) 33 | { 34 | return CGRectMake(values[0], values[1], values[2], values[3]); 35 | } 36 | 37 | #if TARGET_OS_IPHONE 38 | 39 | NS_INLINE UIEdgeInsets values_to_edge_insets(const CGFloat values[]) 40 | { 41 | return UIEdgeInsetsMake(values[0], values[1], values[2], values[3]); 42 | } 43 | 44 | #endif 45 | 46 | NS_INLINE void values_from_point(CGFloat values[], CGPoint p) 47 | { 48 | values[0] = p.x; 49 | values[1] = p.y; 50 | } 51 | 52 | NS_INLINE void values_from_size(CGFloat values[], CGSize s) 53 | { 54 | values[0] = s.width; 55 | values[1] = s.height; 56 | } 57 | 58 | NS_INLINE void values_from_rect(CGFloat values[], CGRect r) 59 | { 60 | values[0] = r.origin.x; 61 | values[1] = r.origin.y; 62 | values[2] = r.size.width; 63 | values[3] = r.size.height; 64 | } 65 | 66 | #if TARGET_OS_IPHONE 67 | 68 | NS_INLINE void values_from_edge_insets(CGFloat values[], UIEdgeInsets i) 69 | { 70 | values[0] = i.top; 71 | values[1] = i.left; 72 | values[2] = i.bottom; 73 | values[3] = i.right; 74 | } 75 | 76 | #endif 77 | 78 | /** 79 | Takes a CGColorRef and converts it into RGBA components, if necessary. 80 | */ 81 | extern void POPCGColorGetRGBAComponents(CGColorRef color, CGFloat components[]); 82 | 83 | /** 84 | Takes RGBA components and returns a CGColorRef. 85 | */ 86 | extern CGColorRef POPCGColorRGBACreate(const CGFloat components[]) CF_RETURNS_RETAINED; 87 | 88 | /** 89 | Takes a color reference and returns a CGColor. 90 | */ 91 | extern CGColorRef POPCGColorWithColor(id color); 92 | 93 | #if TARGET_OS_IPHONE 94 | 95 | /** 96 | Takes a UIColor and converts it into RGBA components, if necessary. 97 | */ 98 | extern void POPUIColorGetRGBAComponents(UIColor *color, CGFloat components[]); 99 | 100 | /** 101 | Takes RGBA components and returns a UIColor. 102 | */ 103 | extern UIColor *POPUIColorRGBACreate(const CGFloat components[]) NS_RETURNS_RETAINED; 104 | 105 | #endif 106 | 107 | POP_EXTERN_C_END 108 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPCGUtils.mm: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPCGUtils.h" 11 | 12 | #if TARGET_OS_IPHONE 13 | #import 14 | #else 15 | #import 16 | #endif 17 | 18 | void POPCGColorGetRGBAComponents(CGColorRef color, CGFloat components[]) 19 | { 20 | if (!color) { 21 | #if TARGET_OS_IPHONE 22 | color = [UIColor clearColor].CGColor; 23 | #else 24 | color = [NSColor clearColor].CGColor; 25 | #endif 26 | } 27 | 28 | const CGFloat *colors = CGColorGetComponents(color); 29 | size_t count = CGColorGetNumberOfComponents(color); 30 | 31 | if (4 == count) { 32 | // RGB colorspace 33 | components[0] = colors[0]; 34 | components[1] = colors[1]; 35 | components[2] = colors[2]; 36 | components[3] = colors[3]; 37 | } else if (2 == count) { 38 | // Grey colorspace 39 | components[0] = components[1] = components[2] = colors[0]; 40 | components[3] = colors[1]; 41 | } else { 42 | // Use CI to convert 43 | CIColor *ciColor = [CIColor colorWithCGColor:color]; 44 | components[0] = ciColor.red; 45 | components[1] = ciColor.green; 46 | components[2] = ciColor.blue; 47 | components[3] = ciColor.alpha; 48 | } 49 | } 50 | 51 | CGColorRef POPCGColorRGBACreate(const CGFloat components[]) 52 | { 53 | #if TARGET_OS_IPHONE 54 | CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB(); 55 | CGColorRef color = CGColorCreate(space, components); 56 | CGColorSpaceRelease(space); 57 | return color; 58 | #else 59 | return CGColorCreateGenericRGB(components[0], components[1], components[2], components[3]); 60 | #endif 61 | } 62 | 63 | CGColorRef POPCGColorWithColor(id color) 64 | { 65 | if (CFGetTypeID((__bridge CFTypeRef)color) == CGColorGetTypeID()) { 66 | return ((__bridge CGColorRef)color); 67 | } 68 | #if TARGET_OS_IPHONE 69 | else if ([color isKindOfClass:[UIColor class]]) { 70 | return [color CGColor]; 71 | } 72 | #else 73 | else if ([color isKindOfClass:[NSColor class]]) { 74 | return [color CGColor]; 75 | } 76 | #endif 77 | return nil; 78 | } 79 | 80 | #if TARGET_OS_IPHONE 81 | 82 | void POPUIColorGetRGBAComponents(UIColor *color, CGFloat components[]) 83 | { 84 | return POPCGColorGetRGBAComponents(color.CGColor, components); 85 | } 86 | 87 | UIColor *POPUIColorRGBACreate(const CGFloat components[]) 88 | { 89 | CGColorRef colorRef = POPCGColorRGBACreate(components); 90 | UIColor *color = [[UIColor alloc] initWithCGColor:colorRef]; 91 | CGColorRelease(colorRef); 92 | return color; 93 | } 94 | 95 | #endif 96 | 97 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPCustomAnimation.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPAnimation.h" 11 | 12 | @class POPCustomAnimation; 13 | 14 | /** 15 | @abstract POPCustomAnimationBlock is the callback block of a custom animation. 16 | @discussion This block will be executed for each animation frame and should update the property or properties being animated based on current timing. 17 | @param target The object being animated. Reference the passed in target to help avoid retain loops. 18 | @param animation The custom animation instance. Use to determine the current and elapsed time since last callback. Reference the passed in animation to help avoid retain loops. 19 | @return Flag indicating whether the animation should continue animating. Return NO to indicate animation is done. 20 | */ 21 | typedef BOOL (^POPCustomAnimationBlock)(id target, POPCustomAnimation *animation); 22 | 23 | /** 24 | @abstract POPCustomAnimation is a concrete animation subclass for custom animations. 25 | */ 26 | @interface POPCustomAnimation : POPAnimation 27 | 28 | /** 29 | @abstract Creates and returns an initialized custom animation instance. 30 | @discussion This is the designated initializer. 31 | @param block The custom animation callback block. See {@ref POPCustomAnimationBlock}. 32 | @return The initialized custom animation instance. 33 | */ 34 | + (instancetype)animationWithBlock:(POPCustomAnimationBlock)block; 35 | 36 | /** 37 | @abstract The current animation time at time of callback. 38 | */ 39 | @property (readonly, nonatomic) CFTimeInterval currentTime; 40 | 41 | /** 42 | @abstract The elapsed animation time since last callback. 43 | */ 44 | @property (readonly, nonatomic) CFTimeInterval elapsedTime; 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPCustomAnimation.mm: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPCustomAnimation.h" 11 | #import "POPAnimationInternal.h" 12 | 13 | @interface POPCustomAnimation () 14 | @property (nonatomic, copy) POPCustomAnimationBlock animate; 15 | @end 16 | 17 | @implementation POPCustomAnimation 18 | @synthesize currentTime = _currentTime; 19 | @synthesize elapsedTime = _elapsedTime; 20 | @synthesize animate = _animate; 21 | 22 | + (instancetype)animationWithBlock:(BOOL(^)(id target, POPCustomAnimation *))block 23 | { 24 | POPCustomAnimation *b = [[self alloc] _init]; 25 | b.animate = block; 26 | return b; 27 | } 28 | 29 | - (id)_init 30 | { 31 | self = [super _init]; 32 | if (nil != self) { 33 | _state->type = kPOPAnimationCustom; 34 | } 35 | return self; 36 | } 37 | 38 | - (CFTimeInterval)beginTime 39 | { 40 | POPAnimationState *s = POPAnimationGetState(self); 41 | return s->startTime > 0 ? s->startTime : s->beginTime; 42 | } 43 | 44 | - (BOOL)_advance:(id)object currentTime:(CFTimeInterval)currentTime elapsedTime:(CFTimeInterval)elapsedTime 45 | { 46 | _currentTime = currentTime; 47 | _elapsedTime = elapsedTime; 48 | return _animate(object, self); 49 | } 50 | 51 | - (void)_appendDescription:(NSMutableString *)s debug:(BOOL)debug 52 | { 53 | [s appendFormat:@"; elapsedTime = %f; currentTime = %f;", _elapsedTime, _currentTime]; 54 | } 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPDecayAnimation.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPPropertyAnimation.h" 11 | 12 | /** 13 | @abstract A concrete decay animation class. 14 | @discussion Animation is achieved through gradual decay of animation value. 15 | */ 16 | @interface POPDecayAnimation : POPPropertyAnimation 17 | 18 | /** 19 | @abstract The designated initializer. 20 | @returns An instance of a decay animation. 21 | */ 22 | + (instancetype)animation; 23 | 24 | /** 25 | @abstract Convenience initializer that returns an animation with animatable property of name. 26 | @param name The name of the animatable property. 27 | @returns An instance of a decay animation configured with specified animatable property. 28 | */ 29 | + (instancetype)animationWithPropertyNamed:(NSString *)name; 30 | 31 | /** 32 | @abstract The current velocity value. 33 | @discussion Set before animation start to account for initial velocity. Expressed in change of value units per second. The only POPValueTypes supported for velocity are: kPOPValuePoint, kPOPValueInteger, kPOPValueFloat, kPOPValueRect, and kPOPValueSize. 34 | */ 35 | @property (copy, nonatomic) id velocity; 36 | 37 | /** 38 | @abstract The original velocity value. 39 | @discussion Since the velocity property is modified as the animation progresses, this property stores the original, passed in velocity to support autoreverse and repeatCount. 40 | */ 41 | @property (copy, nonatomic, readonly) id originalVelocity; 42 | 43 | /** 44 | @abstract The deceleration factor. 45 | @discussion Values specifies should be in the range [0, 1]. Lower values results in faster deceleration. Defaults to 0.998. 46 | */ 47 | @property (assign, nonatomic) CGFloat deceleration; 48 | 49 | /** 50 | @abstract The expected duration. 51 | @discussion Derived based on input velocity and deceleration values. 52 | */ 53 | @property (readonly, assign, nonatomic) CFTimeInterval duration; 54 | 55 | /** 56 | The to value is derived based on input velocity and deceleration. 57 | */ 58 | - (void)setToValue:(id)toValue NS_UNAVAILABLE; 59 | 60 | /** 61 | @abstract The reversed velocity. 62 | @discussion The reversed velocity based on the originalVelocity when the animation was set up. 63 | */ 64 | - (id)reversedVelocity; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPDecayAnimation.mm: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPDecayAnimationInternal.h" 11 | 12 | #if TARGET_OS_IPHONE 13 | #import 14 | #endif 15 | 16 | const POPValueType supportedVelocityTypes[6] = { kPOPValuePoint, kPOPValueInteger, kPOPValueFloat, kPOPValueRect, kPOPValueSize, kPOPValueEdgeInsets }; 17 | 18 | @implementation POPDecayAnimation 19 | 20 | #pragma mark - Lifecycle 21 | 22 | #undef __state 23 | #define __state ((POPDecayAnimationState *)_state) 24 | 25 | + (instancetype)animation 26 | { 27 | return [[self alloc] init]; 28 | } 29 | 30 | + (instancetype)animationWithPropertyNamed:(NSString *)aName 31 | { 32 | POPDecayAnimation *anim = [self animation]; 33 | anim.property = [POPAnimatableProperty propertyWithName:aName]; 34 | return anim; 35 | } 36 | 37 | - (id)init 38 | { 39 | return [self _init]; 40 | } 41 | 42 | - (void)_initState 43 | { 44 | _state = new POPDecayAnimationState(self); 45 | } 46 | 47 | #pragma mark - Properties 48 | 49 | DEFINE_RW_PROPERTY(POPDecayAnimationState, deceleration, setDeceleration:, CGFloat, __state->toVec = NULL;); 50 | 51 | @dynamic velocity; 52 | 53 | - (id)toValue 54 | { 55 | [self _ensureComputedProperties]; 56 | return POPBox(__state->toVec, __state->valueType); 57 | } 58 | 59 | - (CFTimeInterval)duration 60 | { 61 | [self _ensureComputedProperties]; 62 | return __state->duration; 63 | } 64 | 65 | - (void)setFromValue:(id)fromValue 66 | { 67 | super.fromValue = fromValue; 68 | [self _invalidateComputedProperties]; 69 | } 70 | 71 | - (void)setToValue:(id)aValue 72 | { 73 | // no-op 74 | NSLog(@"ignoring to value on decay animation %@", self); 75 | } 76 | 77 | - (id)reversedVelocity 78 | { 79 | id reversedVelocity = nil; 80 | 81 | POPValueType velocityType = POPSelectValueType(self.originalVelocity, supportedVelocityTypes, POP_ARRAY_COUNT(supportedVelocityTypes)); 82 | if (velocityType == kPOPValueFloat) { 83 | CGFloat originalVelocityFloat = [(NSNumber *)self.originalVelocity floatValue]; 84 | NSNumber *negativeOriginalVelocityNumber = @(-originalVelocityFloat); 85 | reversedVelocity = negativeOriginalVelocityNumber; 86 | } else if (velocityType == kPOPValueInteger) { 87 | NSInteger originalVelocityInteger = [(NSNumber *)self.originalVelocity integerValue]; 88 | NSNumber *negativeOriginalVelocityNumber = @(-originalVelocityInteger); 89 | reversedVelocity = negativeOriginalVelocityNumber; 90 | } else if (velocityType == kPOPValuePoint) { 91 | CGPoint originalVelocityPoint = [self.originalVelocity CGPointValue]; 92 | CGPoint negativeOriginalVelocityPoint = CGPointMake(-originalVelocityPoint.x, -originalVelocityPoint.y); 93 | reversedVelocity = [NSValue valueWithCGPoint:negativeOriginalVelocityPoint]; 94 | } else if (velocityType == kPOPValueRect) { 95 | CGRect originalVelocityRect = [self.originalVelocity CGRectValue]; 96 | CGRect negativeOriginalVelocityRect = CGRectMake(-originalVelocityRect.origin.x, -originalVelocityRect.origin.y, -originalVelocityRect.size.width, -originalVelocityRect.size.height); 97 | reversedVelocity = [NSValue valueWithCGRect:negativeOriginalVelocityRect]; 98 | } else if (velocityType == kPOPValueSize) { 99 | CGSize originalVelocitySize = [self.originalVelocity CGSizeValue]; 100 | CGSize negativeOriginalVelocitySize = CGSizeMake(-originalVelocitySize.width, -originalVelocitySize.height); 101 | reversedVelocity = [NSValue valueWithCGSize:negativeOriginalVelocitySize]; 102 | } else if (velocityType == kPOPValueEdgeInsets) { 103 | #if TARGET_OS_IPHONE 104 | UIEdgeInsets originalVelocityInsets = [self.originalVelocity UIEdgeInsetsValue]; 105 | UIEdgeInsets negativeOriginalVelocityInsets = UIEdgeInsetsMake(-originalVelocityInsets.top, -originalVelocityInsets.left, -originalVelocityInsets.bottom, -originalVelocityInsets.right); 106 | reversedVelocity = [NSValue valueWithUIEdgeInsets:negativeOriginalVelocityInsets]; 107 | #endif 108 | } 109 | 110 | return reversedVelocity; 111 | } 112 | 113 | - (id)originalVelocity 114 | { 115 | return POPBox(__state->originalVelocityVec, __state->valueType); 116 | } 117 | 118 | - (id)velocity 119 | { 120 | return POPBox(__state->velocityVec, __state->valueType); 121 | } 122 | 123 | - (void)setVelocity:(id)aValue 124 | { 125 | POPValueType valueType = POPSelectValueType(aValue, supportedVelocityTypes, POP_ARRAY_COUNT(supportedVelocityTypes)); 126 | if (valueType != kPOPValueUnknown) { 127 | VectorRef vec = POPUnbox(aValue, __state->valueType, __state->valueCount, YES); 128 | VectorRef origVec = POPUnbox(aValue, __state->valueType, __state->valueCount, YES); 129 | 130 | if (!vec_equal(vec, __state->velocityVec)) { 131 | __state->velocityVec = vec; 132 | __state->originalVelocityVec = origVec; 133 | 134 | if (__state->tracing) { 135 | [__state->tracer updateVelocity:aValue]; 136 | } 137 | 138 | [self _invalidateComputedProperties]; 139 | 140 | // automatically unpause active animations 141 | if (__state->active && __state->paused) { 142 | __state->fromVec = NULL; 143 | __state->setPaused(false); 144 | } 145 | } 146 | } else { 147 | __state->velocityVec = NULL; 148 | NSLog(@"Invalid velocity value for the decayAnimation: %@", aValue); 149 | } 150 | } 151 | 152 | #pragma mark - Utility 153 | 154 | - (void)_ensureComputedProperties 155 | { 156 | if (NULL == __state->toVec) { 157 | __state->computeDuration(); 158 | __state->computeToValue(); 159 | } 160 | } 161 | 162 | - (void)_invalidateComputedProperties 163 | { 164 | __state->toVec = NULL; 165 | __state->duration = 0; 166 | } 167 | 168 | - (void)_appendDescription:(NSMutableString *)s debug:(BOOL)debug 169 | { 170 | [super _appendDescription:s debug:debug]; 171 | 172 | if (0 != self.duration) { 173 | [s appendFormat:@"; duration = %f", self.duration]; 174 | } 175 | 176 | if (__state->deceleration) { 177 | [s appendFormat:@"; deceleration = %f", __state->deceleration]; 178 | } 179 | } 180 | 181 | @end 182 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPDecayAnimationInternal.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPDecayAnimation.h" 11 | #import "POPPropertyAnimationInternal.h" 12 | 13 | // minimal velocity factor before decay animation is considered complete, in units / s 14 | static CGFloat kPOPAnimationDecayMinimalVelocityFactor = 5.; 15 | 16 | // default decay animation deceleration 17 | static CGFloat kPOPAnimationDecayDecelerationDefault = 0.998; 18 | 19 | static void decay_position(CGFloat *x, CGFloat *v, NSUInteger count, CFTimeInterval dt, CGFloat deceleration) 20 | { 21 | dt *= 1000; 22 | 23 | // v0 = v / 1000 24 | // v = v0 * powf(deceleration, dt); 25 | // v = v * 1000; 26 | 27 | // x0 = x; 28 | // x = x0 + v0 * deceleration * (1 - powf(deceleration, dt)) / (1 - deceleration) 29 | float v0[count]; 30 | float kv = powf(deceleration, dt); 31 | float kx = deceleration * (1 - kv) / (1 - deceleration); 32 | 33 | for (NSUInteger idx = 0; idx < count; idx++) { 34 | v0[idx] = v[idx] / 1000.; 35 | v[idx] = v0[idx] * kv * 1000.; 36 | x[idx] = x[idx] + v0[idx] * kx; 37 | } 38 | } 39 | 40 | struct _POPDecayAnimationState : _POPPropertyAnimationState 41 | { 42 | double deceleration; 43 | CFTimeInterval duration; 44 | 45 | _POPDecayAnimationState(id __unsafe_unretained anim) : 46 | _POPPropertyAnimationState(anim), 47 | deceleration(kPOPAnimationDecayDecelerationDefault), 48 | duration(0) 49 | { 50 | type = kPOPAnimationDecay; 51 | } 52 | 53 | bool isDone() { 54 | if (_POPPropertyAnimationState::isDone()) { 55 | return true; 56 | } 57 | 58 | CGFloat f = dynamicsThreshold * kPOPAnimationDecayMinimalVelocityFactor; 59 | const CGFloat *velocityValues = vec_data(velocityVec); 60 | for (NSUInteger idx = 0; idx < valueCount; idx++) { 61 | //liuliming 62 | if (trunc(fabs(velocityValues[idx])) >= f) 63 | return false; 64 | } 65 | return true; 66 | 67 | } 68 | 69 | void computeDuration() { 70 | 71 | // compute duration till threshold velocity 72 | Vector4r scaledVelocity = vector4(velocityVec) / 1000.; 73 | 74 | double k = dynamicsThreshold * kPOPAnimationDecayMinimalVelocityFactor / 1000.; 75 | double vx = k / scaledVelocity.x; 76 | double vy = k / scaledVelocity.y; 77 | double vz = k / scaledVelocity.z; 78 | double vw = k / scaledVelocity.w; 79 | double d = log(deceleration) * 1000.; 80 | duration = MAX(MAX(MAX(log(fabs(vx)) / d, log(fabs(vy)) / d), log(fabs(vz)) / d), log(fabs(vw)) / d); 81 | 82 | // ensure velocity threshold is exceeded 83 | if (isnan(duration) || duration < 0) { 84 | duration = 0; 85 | } 86 | } 87 | 88 | void computeToValue() { 89 | // to value assuming final velocity as a factor of dynamics threshold 90 | // derived from v' = v * d^dt used in decay_position 91 | // to compute the to value with maximal dt, p' = p + (v * d) / (1 - d) 92 | VectorRef fromValue = NULL != currentVec ? currentVec : fromVec; 93 | if (!fromValue) { 94 | return; 95 | } 96 | 97 | // ensure duration is computed 98 | if (0 == duration) { 99 | computeDuration(); 100 | } 101 | 102 | // compute to value 103 | VectorRef toValue(Vector::new_vector(fromValue.get())); 104 | Vector4r velocity = velocityVec->vector4r(); 105 | decay_position(toValue->data(), velocity.data(), valueCount, duration, deceleration); 106 | toVec = toValue; 107 | } 108 | 109 | void computeDestinationValues() { 110 | // to value assuming final velocity as a factor of dynamics threshold 111 | // derived from v' = v * d^dt used in decay_position 112 | // to compute the to value with maximal dt, p' = p + (v * d) / (1 - d) 113 | VectorRef fromValue = NULL != currentVec ? currentVec : fromVec; 114 | if (!fromValue) { 115 | return; 116 | } 117 | 118 | VectorRef toValue(Vector::new_vector(fromValue.get())); 119 | 120 | // compute duration till threshold velocity 121 | Vector4r scaledVelocity = vector4(velocityVec) / 1000.; 122 | 123 | double k = dynamicsThreshold * kPOPAnimationDecayMinimalVelocityFactor / 1000.; 124 | double vx = k / scaledVelocity.x; 125 | double vy = k / scaledVelocity.y; 126 | double vz = k / scaledVelocity.z; 127 | double vw = k / scaledVelocity.w; 128 | double d = log(deceleration) * 1000.; 129 | duration = MAX(MAX(MAX(log(fabs(vx)) / d, log(fabs(vy)) / d), log(fabs(vz)) / d), log(fabs(vw)) / d); 130 | 131 | // ensure velocity threshold is exceeded 132 | if (isnan(duration) || duration < 0) { 133 | duration = 0; 134 | } else { 135 | // compute to value 136 | Vector4r velocity = velocityVec->vector4r(); 137 | decay_position(toValue->data(), velocity.data(), valueCount, duration, deceleration); 138 | } 139 | 140 | toVec = toValue; 141 | } 142 | 143 | bool advance(CFTimeInterval time, CFTimeInterval dt, id obj) { 144 | // advance past not yet initialized animations 145 | if (NULL == currentVec) { 146 | return false; 147 | } 148 | 149 | decay_position(currentVec->data(), velocityVec->data(), valueCount, dt, deceleration); 150 | 151 | // clamp to compute end value; avoid possibility of decaying past 152 | clampCurrentValue(kPOPAnimationClampEnd | clampMode); 153 | 154 | return true; 155 | } 156 | 157 | }; 158 | 159 | typedef struct _POPDecayAnimationState POPDecayAnimationState; 160 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPDefines.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #ifndef POP_POPDefines_h 11 | #define POP_POPDefines_h 12 | 13 | #ifdef __cplusplus 14 | # define POP_EXTERN_C_BEGIN extern "C" { 15 | # define POP_EXTERN_C_END } 16 | #else 17 | # define POP_EXTERN_C_BEGIN 18 | # define POP_EXTERN_C_END 19 | #endif 20 | 21 | #define POP_ARRAY_COUNT(x) sizeof(x) / sizeof(x[0]) 22 | 23 | #if defined (__cplusplus) && defined (__GNUC__) 24 | # define POP_NOTHROW __attribute__ ((nothrow)) 25 | #else 26 | # define POP_NOTHROW 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPGeometry.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #if TARGET_OS_IPHONE 13 | #import 14 | #endif 15 | 16 | #if !TARGET_OS_IPHONE 17 | 18 | /** NSValue extensions to support animatable types. */ 19 | @interface NSValue (POP) 20 | 21 | /** 22 | @abstract Creates an NSValue given a CGPoint. 23 | */ 24 | + (NSValue *)valueWithCGPoint:(CGPoint)point; 25 | 26 | /** 27 | @abstract Creates an NSValue given a CGSize. 28 | */ 29 | + (NSValue *)valueWithCGSize:(CGSize)size; 30 | 31 | /** 32 | @abstract Creates an NSValue given a CGRect. 33 | */ 34 | + (NSValue *)valueWithCGRect:(CGRect)rect; 35 | 36 | /** 37 | @abstract Creates an NSValue given a CFRange. 38 | */ 39 | + (NSValue *)valueWithCFRange:(CFRange)range; 40 | 41 | /** 42 | @abstract Creates an NSValue given a CGAffineTransform. 43 | */ 44 | + (NSValue *)valueWithCGAffineTransform:(CGAffineTransform)transform; 45 | 46 | /** 47 | @abstract Returns the underlying CGPoint value. 48 | */ 49 | - (CGPoint)CGPointValue; 50 | 51 | /** 52 | @abstract Returns the underlying CGSize value. 53 | */ 54 | - (CGSize)CGSizeValue; 55 | 56 | /** 57 | @abstract Returns the underlying CGRect value. 58 | */ 59 | - (CGRect)CGRectValue; 60 | 61 | /** 62 | @abstract Returns the underlying CFRange value. 63 | */ 64 | - (CFRange)CFRangeValue; 65 | 66 | /** 67 | @abstract Returns the underlying CGAffineTransform value. 68 | */ 69 | - (CGAffineTransform)CGAffineTransformValue; 70 | 71 | @end 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPGeometry.mm: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPGeometry.h" 11 | 12 | #if !TARGET_OS_IPHONE 13 | @implementation NSValue (POP) 14 | 15 | + (NSValue *)valueWithCGPoint:(CGPoint)point { 16 | return [NSValue valueWithBytes:&point objCType:@encode(CGPoint)]; 17 | } 18 | 19 | + (NSValue *)valueWithCGSize:(CGSize)size { 20 | return [NSValue valueWithBytes:&size objCType:@encode(CGSize)]; 21 | } 22 | 23 | + (NSValue *)valueWithCGRect:(CGRect)rect { 24 | return [NSValue valueWithBytes:&rect objCType:@encode(CGRect)]; 25 | } 26 | 27 | + (NSValue *)valueWithCFRange:(CFRange)range { 28 | return [NSValue valueWithBytes:&range objCType:@encode(CFRange)]; 29 | } 30 | 31 | + (NSValue *)valueWithCGAffineTransform:(CGAffineTransform)transform 32 | { 33 | return [NSValue valueWithBytes:&transform objCType:@encode(CGAffineTransform)]; 34 | } 35 | 36 | - (CGPoint)CGPointValue { 37 | CGPoint result; 38 | [self getValue:&result]; 39 | return result; 40 | } 41 | 42 | - (CGSize)CGSizeValue { 43 | CGSize result; 44 | [self getValue:&result]; 45 | return result; 46 | } 47 | 48 | - (CGRect)CGRectValue { 49 | CGRect result; 50 | [self getValue:&result]; 51 | return result; 52 | } 53 | 54 | - (CFRange)CFRangeValue { 55 | CFRange result; 56 | [self getValue:&result]; 57 | return result; 58 | } 59 | 60 | - (CGAffineTransform)CGAffineTransformValue { 61 | CGAffineTransform result; 62 | [self getValue:&result]; 63 | return result; 64 | } 65 | @end 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPLayerExtras.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "POPDefines.h" 13 | 14 | POP_EXTERN_C_BEGIN 15 | 16 | #pragma mark - Scale 17 | 18 | /** 19 | @abstract Returns layer scale factor for the x axis. 20 | */ 21 | extern CGFloat POPLayerGetScaleX(CALayer *l); 22 | 23 | /** 24 | @abstract Set layer scale factor for the x axis. 25 | */ 26 | extern void POPLayerSetScaleX(CALayer *l, CGFloat f); 27 | 28 | /** 29 | @abstract Returns layer scale factor for the y axis. 30 | */ 31 | extern CGFloat POPLayerGetScaleY(CALayer *l); 32 | 33 | /** 34 | @abstract Set layer scale factor for the y axis. 35 | */ 36 | extern void POPLayerSetScaleY(CALayer *l, CGFloat f); 37 | 38 | /** 39 | @abstract Returns layer scale factor for the z axis. 40 | */ 41 | extern CGFloat POPLayerGetScaleZ(CALayer *l); 42 | 43 | /** 44 | @abstract Set layer scale factor for the z axis. 45 | */ 46 | extern void POPLayerSetScaleZ(CALayer *l, CGFloat f); 47 | 48 | /** 49 | @abstract Returns layer scale factors for x and y access as point. 50 | */ 51 | extern CGPoint POPLayerGetScaleXY(CALayer *l); 52 | 53 | /** 54 | @abstract Sets layer x and y scale factors given point. 55 | */ 56 | extern void POPLayerSetScaleXY(CALayer *l, CGPoint p); 57 | 58 | #pragma mark - Translation 59 | 60 | /** 61 | @abstract Returns layer translation factor for the x axis. 62 | */ 63 | extern CGFloat POPLayerGetTranslationX(CALayer *l); 64 | 65 | /** 66 | @abstract Set layer translation factor for the x axis. 67 | */ 68 | extern void POPLayerSetTranslationX(CALayer *l, CGFloat f); 69 | 70 | /** 71 | @abstract Returns layer translation factor for the y axis. 72 | */ 73 | extern CGFloat POPLayerGetTranslationY(CALayer *l); 74 | 75 | /** 76 | @abstract Set layer translation factor for the y axis. 77 | */ 78 | extern void POPLayerSetTranslationY(CALayer *l, CGFloat f); 79 | 80 | /** 81 | @abstract Returns layer translation factor for the z axis. 82 | */ 83 | extern CGFloat POPLayerGetTranslationZ(CALayer *l); 84 | 85 | /** 86 | @abstract Set layer translation factor for the z axis. 87 | */ 88 | extern void POPLayerSetTranslationZ(CALayer *l, CGFloat f); 89 | 90 | /** 91 | @abstract Returns layer translation factors for x and y access as point. 92 | */ 93 | extern CGPoint POPLayerGetTranslationXY(CALayer *l); 94 | 95 | /** 96 | @abstract Sets layer x and y translation factors given point. 97 | */ 98 | extern void POPLayerSetTranslationXY(CALayer *l, CGPoint p); 99 | 100 | #pragma mark - Rotation 101 | 102 | /** 103 | @abstract Returns layer rotation, in radians, in the X axis. 104 | */ 105 | extern CGFloat POPLayerGetRotationX(CALayer *l); 106 | 107 | /** 108 | @abstract Sets layer rotation, in radians, in the X axis. 109 | */ 110 | extern void POPLayerSetRotationX(CALayer *l, CGFloat f); 111 | 112 | /** 113 | @abstract Returns layer rotation, in radians, in the Y axis. 114 | */ 115 | extern CGFloat POPLayerGetRotationY(CALayer *l); 116 | 117 | /** 118 | @abstract Sets layer rotation, in radians, in the Y axis. 119 | */ 120 | extern void POPLayerSetRotationY(CALayer *l, CGFloat f); 121 | 122 | /** 123 | @abstract Returns layer rotation, in radians, in the Z axis. 124 | */ 125 | extern CGFloat POPLayerGetRotationZ(CALayer *l); 126 | 127 | /** 128 | @abstract Sets layer rotation, in radians, in the Z axis. 129 | */ 130 | extern void POPLayerSetRotationZ(CALayer *l, CGFloat f); 131 | 132 | /** 133 | @abstract Returns layer rotation, in radians, in the Z axis. 134 | */ 135 | extern CGFloat POPLayerGetRotation(CALayer *l); 136 | 137 | /** 138 | @abstract Sets layer rotation, in radians, in the Z axis. 139 | */ 140 | extern void POPLayerSetRotation(CALayer *l, CGFloat f); 141 | 142 | #pragma mark - Sublayer Scale 143 | 144 | /** 145 | @abstract Returns sublayer scale factors for x and y access as point. 146 | */ 147 | extern CGPoint POPLayerGetSubScaleXY(CALayer *l); 148 | 149 | /** 150 | @abstract Sets sublayer x and y scale factors given point. 151 | */ 152 | extern void POPLayerSetSubScaleXY(CALayer *l, CGPoint p); 153 | 154 | #pragma mark - Sublayer Translation 155 | 156 | /** 157 | @abstract Returns sublayer translation factor for the x axis. 158 | */ 159 | extern CGFloat POPLayerGetSubTranslationX(CALayer *l); 160 | 161 | /** 162 | @abstract Set sublayer translation factor for the x axis. 163 | */ 164 | extern void POPLayerSetSubTranslationX(CALayer *l, CGFloat f); 165 | 166 | /** 167 | @abstract Returns sublayer translation factor for the y axis. 168 | */ 169 | extern CGFloat POPLayerGetSubTranslationY(CALayer *l); 170 | 171 | /** 172 | @abstract Set sublayer translation factor for the y axis. 173 | */ 174 | extern void POPLayerSetSubTranslationY(CALayer *l, CGFloat f); 175 | 176 | /** 177 | @abstract Returns sublayer translation factor for the z axis. 178 | */ 179 | extern CGFloat POPLayerGetSubTranslationZ(CALayer *l); 180 | 181 | /** 182 | @abstract Set sublayer translation factor for the z axis. 183 | */ 184 | extern void POPLayerSetSubTranslationZ(CALayer *l, CGFloat f); 185 | 186 | /** 187 | @abstract Returns sublayer translation factors for x and y access as point. 188 | */ 189 | extern CGPoint POPLayerGetSubTranslationXY(CALayer *l); 190 | 191 | /** 192 | @abstract Sets sublayer x and y translation factors given point. 193 | */ 194 | extern void POPLayerSetSubTranslationXY(CALayer *l, CGPoint p); 195 | 196 | POP_EXTERN_C_END 197 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPLayerExtras.mm: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPLayerExtras.h" 11 | 12 | #include "TransformationMatrix.h" 13 | 14 | using namespace WebCore; 15 | 16 | #define DECOMPOSE_TRANSFORM(L) \ 17 | TransformationMatrix _m(L.transform); \ 18 | TransformationMatrix::DecomposedType _d; \ 19 | _m.decompose(_d); 20 | 21 | #define RECOMPOSE_TRANSFORM(L) \ 22 | _m.recompose(_d); \ 23 | L.transform = _m.transform3d(); 24 | 25 | #define RECOMPOSE_ROT_TRANSFORM(L) \ 26 | _m.recompose(_d, true); \ 27 | L.transform = _m.transform3d(); 28 | 29 | #define DECOMPOSE_SUBLAYER_TRANSFORM(L) \ 30 | TransformationMatrix _m(L.sublayerTransform); \ 31 | TransformationMatrix::DecomposedType _d; \ 32 | _m.decompose(_d); 33 | 34 | #define RECOMPOSE_SUBLAYER_TRANSFORM(L) \ 35 | _m.recompose(_d); \ 36 | L.sublayerTransform = _m.transform3d(); 37 | 38 | #pragma mark - Scale 39 | 40 | NS_INLINE void ensureNonZeroValue(CGFloat &f) 41 | { 42 | if (f == 0) { 43 | f = 1e-6; 44 | } 45 | } 46 | 47 | NS_INLINE void ensureNonZeroValue(CGPoint &p) 48 | { 49 | if (p.x == 0 && p.y == 0) { 50 | p.x = 1e-6; 51 | p.y = 1e-6; 52 | } 53 | } 54 | 55 | CGFloat POPLayerGetScaleX(CALayer *l) 56 | { 57 | DECOMPOSE_TRANSFORM(l); 58 | return _d.scaleX; 59 | } 60 | 61 | void POPLayerSetScaleX(CALayer *l, CGFloat f) 62 | { 63 | ensureNonZeroValue(f); 64 | DECOMPOSE_TRANSFORM(l); 65 | _d.scaleX = f; 66 | RECOMPOSE_TRANSFORM(l); 67 | } 68 | 69 | CGFloat POPLayerGetScaleY(CALayer *l) 70 | { 71 | DECOMPOSE_TRANSFORM(l); 72 | return _d.scaleY; 73 | } 74 | 75 | void POPLayerSetScaleY(CALayer *l, CGFloat f) 76 | { 77 | ensureNonZeroValue(f); 78 | DECOMPOSE_TRANSFORM(l); 79 | _d.scaleY = f; 80 | RECOMPOSE_TRANSFORM(l); 81 | } 82 | 83 | CGFloat POPLayerGetScaleZ(CALayer *l) 84 | { 85 | DECOMPOSE_TRANSFORM(l); 86 | return _d.scaleZ; 87 | } 88 | 89 | void POPLayerSetScaleZ(CALayer *l, CGFloat f) 90 | { 91 | ensureNonZeroValue(f); 92 | DECOMPOSE_TRANSFORM(l); 93 | _d.scaleZ = f; 94 | RECOMPOSE_TRANSFORM(l); 95 | } 96 | 97 | CGPoint POPLayerGetScaleXY(CALayer *l) 98 | { 99 | DECOMPOSE_TRANSFORM(l); 100 | return CGPointMake(_d.scaleX, _d.scaleY); 101 | } 102 | 103 | void POPLayerSetScaleXY(CALayer *l, CGPoint p) 104 | { 105 | ensureNonZeroValue(p); 106 | DECOMPOSE_TRANSFORM(l); 107 | _d.scaleX = p.x; 108 | _d.scaleY = p.y; 109 | RECOMPOSE_TRANSFORM(l); 110 | } 111 | 112 | #pragma mark - Translation 113 | 114 | CGFloat POPLayerGetTranslationX(CALayer *l) 115 | { 116 | DECOMPOSE_TRANSFORM(l); 117 | return _d.translateX; 118 | } 119 | 120 | void POPLayerSetTranslationX(CALayer *l, CGFloat f) 121 | { 122 | DECOMPOSE_TRANSFORM(l); 123 | _d.translateX = f; 124 | RECOMPOSE_TRANSFORM(l); 125 | } 126 | 127 | CGFloat POPLayerGetTranslationY(CALayer *l) 128 | { 129 | DECOMPOSE_TRANSFORM(l); 130 | return _d.translateY; 131 | } 132 | 133 | void POPLayerSetTranslationY(CALayer *l, CGFloat f) 134 | { 135 | DECOMPOSE_TRANSFORM(l); 136 | _d.translateY = f; 137 | RECOMPOSE_TRANSFORM(l); 138 | } 139 | 140 | CGFloat POPLayerGetTranslationZ(CALayer *l) 141 | { 142 | DECOMPOSE_TRANSFORM(l); 143 | return _d.translateZ; 144 | } 145 | 146 | void POPLayerSetTranslationZ(CALayer *l, CGFloat f) 147 | { 148 | DECOMPOSE_TRANSFORM(l); 149 | _d.translateZ = f; 150 | RECOMPOSE_TRANSFORM(l); 151 | } 152 | 153 | CGPoint POPLayerGetTranslationXY(CALayer *l) 154 | { 155 | DECOMPOSE_TRANSFORM(l); 156 | return CGPointMake(_d.translateX, _d.translateY); 157 | } 158 | 159 | void POPLayerSetTranslationXY(CALayer *l, CGPoint p) 160 | { 161 | DECOMPOSE_TRANSFORM(l); 162 | _d.translateX = p.x; 163 | _d.translateY = p.y; 164 | RECOMPOSE_TRANSFORM(l); 165 | } 166 | 167 | #pragma mark - Rotation 168 | 169 | CGFloat POPLayerGetRotationX(CALayer *l) 170 | { 171 | DECOMPOSE_TRANSFORM(l); 172 | return _d.rotateX; 173 | } 174 | 175 | void POPLayerSetRotationX(CALayer *l, CGFloat f) 176 | { 177 | DECOMPOSE_TRANSFORM(l); 178 | _d.rotateX = f; 179 | RECOMPOSE_ROT_TRANSFORM(l); 180 | } 181 | 182 | CGFloat POPLayerGetRotationY(CALayer *l) 183 | { 184 | DECOMPOSE_TRANSFORM(l); 185 | return _d.rotateY; 186 | } 187 | 188 | void POPLayerSetRotationY(CALayer *l, CGFloat f) 189 | { 190 | DECOMPOSE_TRANSFORM(l); 191 | _d.rotateY = f; 192 | RECOMPOSE_ROT_TRANSFORM(l); 193 | } 194 | 195 | CGFloat POPLayerGetRotationZ(CALayer *l) 196 | { 197 | DECOMPOSE_TRANSFORM(l); 198 | return _d.rotateZ; 199 | } 200 | 201 | void POPLayerSetRotationZ(CALayer *l, CGFloat f) 202 | { 203 | DECOMPOSE_TRANSFORM(l); 204 | _d.rotateZ = f; 205 | RECOMPOSE_ROT_TRANSFORM(l); 206 | } 207 | 208 | CGFloat POPLayerGetRotation(CALayer *l) 209 | { 210 | return POPLayerGetRotationZ(l); 211 | } 212 | 213 | void POPLayerSetRotation(CALayer *l, CGFloat f) 214 | { 215 | POPLayerSetRotationZ(l, f); 216 | } 217 | 218 | #pragma mark - Sublayer Scale 219 | 220 | CGPoint POPLayerGetSubScaleXY(CALayer *l) 221 | { 222 | DECOMPOSE_SUBLAYER_TRANSFORM(l); 223 | return CGPointMake(_d.scaleX, _d.scaleY); 224 | } 225 | 226 | void POPLayerSetSubScaleXY(CALayer *l, CGPoint p) 227 | { 228 | ensureNonZeroValue(p); 229 | DECOMPOSE_SUBLAYER_TRANSFORM(l); 230 | _d.scaleX = p.x; 231 | _d.scaleY = p.y; 232 | RECOMPOSE_SUBLAYER_TRANSFORM(l); 233 | } 234 | 235 | #pragma mark - Sublayer Translation 236 | 237 | extern CGFloat POPLayerGetSubTranslationX(CALayer *l) 238 | { 239 | DECOMPOSE_SUBLAYER_TRANSFORM(l); 240 | return _d.translateX; 241 | } 242 | 243 | extern void POPLayerSetSubTranslationX(CALayer *l, CGFloat f) 244 | { 245 | DECOMPOSE_SUBLAYER_TRANSFORM(l); 246 | _d.translateX = f; 247 | RECOMPOSE_SUBLAYER_TRANSFORM(l); 248 | } 249 | 250 | extern CGFloat POPLayerGetSubTranslationY(CALayer *l) 251 | { 252 | DECOMPOSE_SUBLAYER_TRANSFORM(l); 253 | return _d.translateY; 254 | } 255 | 256 | extern void POPLayerSetSubTranslationY(CALayer *l, CGFloat f) 257 | { 258 | DECOMPOSE_SUBLAYER_TRANSFORM(l); 259 | _d.translateY = f; 260 | RECOMPOSE_SUBLAYER_TRANSFORM(l); 261 | } 262 | 263 | extern CGFloat POPLayerGetSubTranslationZ(CALayer *l) 264 | { 265 | DECOMPOSE_SUBLAYER_TRANSFORM(l); 266 | return _d.translateZ; 267 | } 268 | 269 | extern void POPLayerSetSubTranslationZ(CALayer *l, CGFloat f) 270 | { 271 | DECOMPOSE_SUBLAYER_TRANSFORM(l); 272 | _d.translateZ = f; 273 | RECOMPOSE_SUBLAYER_TRANSFORM(l); 274 | } 275 | 276 | extern CGPoint POPLayerGetSubTranslationXY(CALayer *l) 277 | { 278 | DECOMPOSE_SUBLAYER_TRANSFORM(l); 279 | return CGPointMake(_d.translateX, _d.translateY); 280 | } 281 | 282 | extern void POPLayerSetSubTranslationXY(CALayer *l, CGPoint p) 283 | { 284 | DECOMPOSE_SUBLAYER_TRANSFORM(l); 285 | _d.translateX = p.x; 286 | _d.translateY = p.y; 287 | RECOMPOSE_SUBLAYER_TRANSFORM(l); 288 | } 289 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPMath.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import "POPDefines.h" 14 | #import "POPVector.h" 15 | 16 | NS_INLINE CGFloat sqrtr(CGFloat f) 17 | { 18 | #if CGFLOAT_IS_DOUBLE 19 | return sqrt(f); 20 | #else 21 | return sqrtf(f); 22 | #endif 23 | } 24 | 25 | // round to nearest sub; pass 2.0 to round to every 0.5 (eg: retina pixels) 26 | NS_INLINE CGFloat POPSubRound(CGFloat f, CGFloat sub) 27 | { 28 | return round(f * sub) / sub; 29 | } 30 | 31 | #define MIX(a, b, f) ((a) + (f) * ((b) - (a))) 32 | 33 | // the longer the duration, the higher the necessary precision 34 | #define SOLVE_EPS(dur) (1. / (1000. * (dur))) 35 | 36 | #define _EQLF_(x, y, epsilon) (fabsf ((x) - (y)) < epsilon) 37 | 38 | extern void POPInterpolateVector(NSUInteger count, CGFloat *dst, const CGFloat *from, const CGFloat *to, CGFloat f); 39 | 40 | extern double POPTimingFunctionSolve(const double vec[4], double t, double eps); 41 | 42 | // quadratic mapping of t [0, 1] to [start, end] 43 | extern double POPQuadraticOutInterpolation(double t, double start, double end); 44 | 45 | // normalize value to [0, 1] based on its range [startValue, endValue] 46 | extern double POPNormalize(double value, double startValue, double endValue); 47 | 48 | // project a normalized value [0, 1] to a given range [start, end] 49 | extern double POPProjectNormal(double n, double start, double end); 50 | 51 | // solve a quadratic equation of the form a * x^2 + b * x + c = 0 52 | extern void POPQuadraticSolve(CGFloat a, CGFloat b, CGFloat c, CGFloat &x1, CGFloat &x2); 53 | 54 | // for a given tension return the bouncy 3 friction that produces no bounce 55 | extern double POPBouncy3NoBounce(double tension); 56 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPMath.mm: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPMath.h" 11 | #import "UnitBezier.h" 12 | #import "POPAnimationPrivate.h" 13 | 14 | void POPInterpolateVector(NSUInteger count, CGFloat *dst, const CGFloat *from, const CGFloat *to, CGFloat f) 15 | { 16 | for (NSUInteger idx = 0; idx < count; idx++) { 17 | dst[idx] = MIX(from[idx], to[idx], f); 18 | } 19 | } 20 | 21 | double POPTimingFunctionSolve(const double vec[4], double t, double eps) 22 | { 23 | WebCore::UnitBezier bezier(vec[0], vec[1], vec[2], vec[3]); 24 | return bezier.solve(t, eps); 25 | } 26 | 27 | double POPNormalize(double value, double startValue, double endValue) 28 | { 29 | return (value - startValue) / (endValue - startValue); 30 | } 31 | 32 | double POPProjectNormal(double n, double start, double end) 33 | { 34 | return start + (n * (end - start)); 35 | } 36 | 37 | static double linear_interpolation(double t, double start, double end) 38 | { 39 | return t * end + (1.f - t) * start; 40 | } 41 | 42 | double POPQuadraticOutInterpolation(double t, double start, double end) 43 | { 44 | return linear_interpolation(2*t - t*t, start, end); 45 | } 46 | 47 | static double b3_friction1(double x) 48 | { 49 | return (0.0007 * pow(x, 3)) - (0.031 * pow(x, 2)) + 0.64 * x + 1.28; 50 | } 51 | 52 | static double b3_friction2(double x) 53 | { 54 | return (0.000044 * pow(x, 3)) - (0.006 * pow(x, 2)) + 0.36 * x + 2.; 55 | } 56 | 57 | static double b3_friction3(double x) 58 | { 59 | return (0.00000045 * pow(x, 3)) - (0.000332 * pow(x, 2)) + 0.1078 * x + 5.84; 60 | } 61 | 62 | double POPBouncy3NoBounce(double tension) 63 | { 64 | double friction = 0; 65 | if (tension <= 18.) { 66 | friction = b3_friction1(tension); 67 | } else if (tension > 18 && tension <= 44) { 68 | friction = b3_friction2(tension); 69 | } else if (tension > 44) { 70 | friction = b3_friction3(tension); 71 | } else { 72 | assert(false); 73 | } 74 | return friction; 75 | } 76 | 77 | void POPQuadraticSolve(CGFloat a, CGFloat b, CGFloat c, CGFloat &x1, CGFloat &x2) 78 | { 79 | CGFloat discriminant = sqrt(b * b - 4 * a * c); 80 | x1 = (-b + discriminant) / (2 * a); 81 | x2 = (-b - discriminant) / (2 * a); 82 | } 83 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPPropertyAnimation.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPAnimatableProperty.h" 11 | #import "POPAnimation.h" 12 | 13 | /** 14 | @abstract Flags for clamping animation values. 15 | @discussion Animation values can optionally be clamped to avoid overshoot. kPOPAnimationClampStart ensures values are more than fromValue and kPOPAnimationClampEnd ensures values are less than toValue. 16 | */ 17 | typedef NS_OPTIONS(NSUInteger, POPAnimationClampFlags) 18 | { 19 | kPOPAnimationClampNone = 0, 20 | kPOPAnimationClampStart = 1UL << 0, 21 | kPOPAnimationClampEnd = 1UL << 1, 22 | kPOPAnimationClampBoth = kPOPAnimationClampStart | kPOPAnimationClampEnd, 23 | }; 24 | 25 | /** 26 | @abstract The semi-concrete property animation subclass. 27 | */ 28 | @interface POPPropertyAnimation : POPAnimation 29 | 30 | /** 31 | @abstract The property to animate. 32 | */ 33 | @property (strong, nonatomic) POPAnimatableProperty *property; 34 | 35 | /** 36 | @abstract The value to animate from. 37 | @discussion The value type should match the property. If unspecified, the value is initialized to the object's current value on animation start. 38 | */ 39 | @property (copy, nonatomic) id fromValue; 40 | 41 | /** 42 | @abstract The value to animate to. 43 | @discussion The value type should match the property. If unspecified, the value is initialized to the object's current value on animation start. 44 | */ 45 | @property (copy, nonatomic) id toValue; 46 | 47 | /** 48 | @abstract The rounding factor applied to the current animated value. 49 | @discussion Specify 1.0 to animate between integral values. Defaults to 0 meaning no rounding. 50 | */ 51 | @property (assign, nonatomic) CGFloat roundingFactor; 52 | 53 | /** 54 | @abstract The clamp mode applied to the current animated value. 55 | @discussion See {@ref POPAnimationClampFlags} for possible values. Defaults to kPOPAnimationClampNone. 56 | */ 57 | @property (assign, nonatomic) NSUInteger clampMode; 58 | 59 | /** 60 | @abstract The flag indicating whether values should be "added" each frame, rather than set. 61 | @discussion Addition may be type dependent. Defaults to NO. 62 | */ 63 | @property (assign, nonatomic, getter = isAdditive) BOOL additive; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPPropertyAnimation.mm: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPPropertyAnimationInternal.h" 11 | 12 | @implementation POPPropertyAnimation 13 | 14 | #pragma mark - Lifecycle 15 | 16 | #undef __state 17 | #define __state ((POPPropertyAnimationState *)_state) 18 | 19 | - (void)_initState 20 | { 21 | _state = new POPPropertyAnimationState(self); 22 | } 23 | 24 | #pragma mark - Properties 25 | 26 | DEFINE_RW_FLAG(POPPropertyAnimationState, additive, isAdditive, setAdditive:); 27 | DEFINE_RW_PROPERTY(POPPropertyAnimationState, roundingFactor, setRoundingFactor:, CGFloat); 28 | DEFINE_RW_PROPERTY(POPPropertyAnimationState, clampMode, setClampMode:, NSUInteger); 29 | DEFINE_RW_PROPERTY_OBJ(POPPropertyAnimationState, property, setProperty:, POPAnimatableProperty*, ((POPPropertyAnimationState*)_state)->updatedDynamicsThreshold();); 30 | DEFINE_RW_PROPERTY_OBJ_COPY(POPPropertyAnimationState, progressMarkers, setProgressMarkers:, NSArray*, ((POPPropertyAnimationState*)_state)->updatedProgressMarkers();); 31 | 32 | - (id)fromValue 33 | { 34 | return POPBox(__state->fromVec, __state->valueType); 35 | } 36 | 37 | - (void)setFromValue:(id)aValue 38 | { 39 | POPPropertyAnimationState *s = __state; 40 | VectorRef vec = POPUnbox(aValue, s->valueType, s->valueCount, YES); 41 | if (!vec_equal(vec, s->fromVec)) { 42 | s->fromVec = vec; 43 | 44 | if (s->tracing) { 45 | [s->tracer updateFromValue:aValue]; 46 | } 47 | } 48 | } 49 | 50 | - (id)toValue 51 | { 52 | return POPBox(__state->toVec, __state->valueType); 53 | } 54 | 55 | - (void)setToValue:(id)aValue 56 | { 57 | POPPropertyAnimationState *s = __state; 58 | VectorRef vec = POPUnbox(aValue, s->valueType, s->valueCount, YES); 59 | 60 | if (!vec_equal(vec, s->toVec)) { 61 | s->toVec = vec; 62 | 63 | // invalidate to dependent state 64 | s->didReachToValue = false; 65 | s->distanceVec = NULL; 66 | 67 | if (s->tracing) { 68 | [s->tracer updateToValue:aValue]; 69 | } 70 | 71 | // automatically unpause active animations 72 | if (s->active && s->paused) { 73 | s->setPaused(false); 74 | } 75 | } 76 | } 77 | 78 | - (id)currentValue 79 | { 80 | return POPBox(__state->currentValue(), __state->valueType); 81 | } 82 | 83 | #pragma mark - Utility 84 | 85 | - (void)_appendDescription:(NSMutableString *)s debug:(BOOL)debug 86 | { 87 | [s appendFormat:@"; from = %@; to = %@", describe(__state->fromVec), describe(__state->toVec)]; 88 | 89 | if (_state->active) 90 | [s appendFormat:@"; currentValue = %@", describe(__state->currentValue())]; 91 | 92 | if (__state->velocityVec && 0 != __state->velocityVec->norm()) 93 | [s appendFormat:@"; velocity = %@", describe(__state->velocityVec)]; 94 | 95 | if (!self.removedOnCompletion) 96 | [s appendFormat:@"; removedOnCompletion = %@", POPStringFromBOOL(self.removedOnCompletion)]; 97 | 98 | if (__state->progressMarkers) 99 | [s appendFormat:@"; progressMarkers = [%@]", [__state->progressMarkers componentsJoinedByString:@", "]]; 100 | 101 | if (_state->active) 102 | [s appendFormat:@"; progress = %f", __state->progress]; 103 | } 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPSpringAnimation.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPPropertyAnimation.h" 11 | 12 | /** 13 | @abstract A concrete spring animation class. 14 | @discussion Animation is achieved through modeling spring dynamics. 15 | */ 16 | @interface POPSpringAnimation : POPPropertyAnimation 17 | 18 | /** 19 | @abstract The designated initializer. 20 | @returns An instance of a spring animation. 21 | */ 22 | + (instancetype)animation; 23 | 24 | /** 25 | @abstract Convenience initializer that returns an animation with animatable property of name. 26 | @param name The name of the animatable property. 27 | @returns An instance of a spring animation configured with specified animatable property. 28 | */ 29 | + (instancetype)animationWithPropertyNamed:(NSString *)name; 30 | 31 | /** 32 | @abstract The current velocity value. 33 | @discussion Set before animation start to account for initial velocity. Expressed in change of value units per second. 34 | */ 35 | @property (copy, nonatomic) id velocity; 36 | 37 | /** 38 | @abstract The effective bounciness. 39 | @discussion Use in conjunction with 'springSpeed' to change animation effect. Values are converted into corresponding dynamics constants. Defined as a value in the range [0, 20]. Defaults to 4. 40 | */ 41 | @property (assign, nonatomic) CGFloat springBounciness; 42 | 43 | /** 44 | @abstract The effective speed. 45 | @discussion Use in conjunction with 'springBounciness' to change animation effect. Values are converted into corresponding dynamics constants. Defined as a value in the range [0, 20]. Defaults to 12. 46 | */ 47 | @property (assign, nonatomic) CGFloat springSpeed; 48 | 49 | /** 50 | @abstract The tension used in the dynamics simulation. 51 | @discussion Can be used over bounciness and speed for finer grain tweaking of animation effect. 52 | */ 53 | @property (assign, nonatomic) CGFloat dynamicsTension; 54 | 55 | /** 56 | @abstract The friction used in the dynamics simulation. 57 | @discussion Can be used over bounciness and speed for finer grain tweaking of animation effect. 58 | */ 59 | @property (assign, nonatomic) CGFloat dynamicsFriction; 60 | 61 | /** 62 | @abstract The mass used in the dynamics simulation. 63 | @discussion Can be used over bounciness and speed for finer grain tweaking of animation effect. 64 | */ 65 | @property (assign, nonatomic) CGFloat dynamicsMass; 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPSpringAnimation.mm: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPSpringAnimationInternal.h" 11 | 12 | @implementation POPSpringAnimation 13 | 14 | #pragma mark - Lifecycle 15 | 16 | #undef __state 17 | #define __state ((POPSpringAnimationState *)_state) 18 | 19 | + (instancetype)animation 20 | { 21 | return [[self alloc] init]; 22 | } 23 | 24 | + (instancetype)animationWithPropertyNamed:(NSString *)aName 25 | { 26 | POPSpringAnimation *anim = [self animation]; 27 | anim.property = [POPAnimatableProperty propertyWithName:aName]; 28 | return anim; 29 | } 30 | 31 | - (void)_initState 32 | { 33 | _state = new POPSpringAnimationState(self); 34 | } 35 | 36 | - (id)init 37 | { 38 | self = [super _init]; 39 | if (nil != self) { 40 | __state->solver = new SpringSolver4d(1, 1, 1); 41 | __state->updatedDynamicsThreshold(); 42 | __state->updatedBouncinessAndSpeed(); 43 | } 44 | return self; 45 | } 46 | 47 | - (void)dealloc 48 | { 49 | if (__state) { 50 | delete __state->solver; 51 | __state->solver = NULL; 52 | } 53 | } 54 | 55 | #pragma mark - Properties 56 | 57 | - (id)velocity 58 | { 59 | return POPBox(__state->velocityVec, __state->valueType); 60 | } 61 | 62 | - (void)setVelocity:(id)aValue 63 | { 64 | POPPropertyAnimationState *s = __state; 65 | VectorRef vec = POPUnbox(aValue, s->valueType, s->valueCount, YES); 66 | if (!vec_equal(vec, s->velocityVec)) { 67 | s->velocityVec = vec; 68 | 69 | if (s->tracing) { 70 | [s->tracer updateVelocity:aValue]; 71 | } 72 | } 73 | } 74 | 75 | DEFINE_RW_PROPERTY(POPSpringAnimationState, dynamicsTension, setDynamicsTension:, CGFloat, [self _updatedDynamicsTension];); 76 | DEFINE_RW_PROPERTY(POPSpringAnimationState, dynamicsFriction, setDynamicsFriction:, CGFloat, [self _updatedDynamicsFriction];); 77 | DEFINE_RW_PROPERTY(POPSpringAnimationState, dynamicsMass, setDynamicsMass:, CGFloat, [self _updatedDynamicsMass];); 78 | 79 | FB_PROPERTY_GET(POPSpringAnimationState, springSpeed, CGFloat); 80 | - (void)setSpringSpeed:(CGFloat)aFloat 81 | { 82 | POPSpringAnimationState *s = __state; 83 | if (s->userSpecifiedDynamics || aFloat != s->springSpeed) { 84 | s->springSpeed = aFloat; 85 | s->userSpecifiedDynamics = false; 86 | s->updatedBouncinessAndSpeed(); 87 | if (s->tracing) { 88 | [s->tracer updateSpeed:aFloat]; 89 | } 90 | } 91 | } 92 | 93 | FB_PROPERTY_GET(POPSpringAnimationState, springBounciness, CGFloat); 94 | - (void)setSpringBounciness:(CGFloat)aFloat 95 | { 96 | POPSpringAnimationState *s = __state; 97 | if (s->userSpecifiedDynamics || aFloat != s->springBounciness) { 98 | s->springBounciness = aFloat; 99 | s->userSpecifiedDynamics = false; 100 | s->updatedBouncinessAndSpeed(); 101 | if (s->tracing) { 102 | [s->tracer updateBounciness:aFloat]; 103 | } 104 | } 105 | } 106 | 107 | - (SpringSolver4d *)solver 108 | { 109 | return __state->solver; 110 | } 111 | 112 | - (void)setSolver:(SpringSolver4d *)aSolver 113 | { 114 | if (aSolver != __state->solver) { 115 | if (__state->solver) { 116 | delete(__state->solver); 117 | } 118 | __state->solver = aSolver; 119 | } 120 | } 121 | 122 | #pragma mark - Utility 123 | 124 | - (void)_updatedDynamicsTension 125 | { 126 | __state->userSpecifiedDynamics = true; 127 | if(__state->tracing) { 128 | [__state->tracer updateTension:__state->dynamicsTension]; 129 | } 130 | __state->updatedDynamics(); 131 | } 132 | 133 | - (void)_updatedDynamicsFriction 134 | { 135 | __state->userSpecifiedDynamics = true; 136 | if(__state->tracing) { 137 | [__state->tracer updateFriction:__state->dynamicsFriction]; 138 | } 139 | __state->updatedDynamics(); 140 | } 141 | 142 | - (void)_updatedDynamicsMass 143 | { 144 | __state->userSpecifiedDynamics = true; 145 | if(__state->tracing) { 146 | [__state->tracer updateMass:__state->dynamicsMass]; 147 | } 148 | __state->updatedDynamics(); 149 | } 150 | 151 | - (void)_appendDescription:(NSMutableString *)s debug:(BOOL)debug 152 | { 153 | [super _appendDescription:s debug:debug]; 154 | 155 | if (debug) { 156 | if (_state->userSpecifiedDynamics) { 157 | [s appendFormat:@"; dynamics = (tension:%f, friction:%f, mass:%f)", __state->dynamicsTension, __state->dynamicsFriction, __state->dynamicsMass]; 158 | } else { 159 | [s appendFormat:@"; bounciness = %f; speed = %f", __state->springBounciness, __state->springSpeed]; 160 | } 161 | } 162 | } 163 | 164 | @end 165 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPSpringAnimationInternal.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "POPAnimationExtras.h" 11 | #import "POPPropertyAnimationInternal.h" 12 | 13 | struct _POPSpringAnimationState : _POPPropertyAnimationState 14 | { 15 | SpringSolver4d *solver; 16 | CGFloat springSpeed; 17 | CGFloat springBounciness; // normalized springiness 18 | CGFloat dynamicsTension; // tension 19 | CGFloat dynamicsFriction; // friction 20 | CGFloat dynamicsMass; // mass 21 | 22 | _POPSpringAnimationState(id __unsafe_unretained anim) : _POPPropertyAnimationState(anim), 23 | solver(nullptr), 24 | springSpeed(12.), 25 | springBounciness(4.), 26 | dynamicsTension(0), 27 | dynamicsFriction(0), 28 | dynamicsMass(0) 29 | { 30 | type = kPOPAnimationSpring; 31 | } 32 | 33 | bool hasConverged() 34 | { 35 | NSUInteger count = valueCount; 36 | if (shouldRound()) { 37 | return vec_equal(previous2Vec, previousVec) && vec_equal(previousVec, toVec); 38 | } else { 39 | if (!previousVec || !previous2Vec) 40 | return false; 41 | 42 | CGFloat t = dynamicsThreshold / 5; 43 | 44 | const CGFloat *toValues = toVec->data(); 45 | const CGFloat *previousValues = previousVec->data(); 46 | const CGFloat *previous2Values = previous2Vec->data(); 47 | 48 | for (NSUInteger idx = 0; idx < count; idx++) { 49 | if ((trunc(fabs(toValues[idx] - previousValues[idx])) >= t) || (fabs(previous2Values[idx] - previousValues[idx]) >= t)) { 50 | return false; 51 | } 52 | } 53 | return true; 54 | } 55 | } 56 | 57 | bool isDone() { 58 | if (_POPPropertyAnimationState::isDone()) { 59 | return true; 60 | } 61 | return solver->started() && (hasConverged() || solver->hasConverged()); 62 | } 63 | 64 | void updatedDynamics() 65 | { 66 | if (NULL != solver) { 67 | solver->setConstants(dynamicsTension, dynamicsFriction, dynamicsMass); 68 | } 69 | } 70 | 71 | void updatedDynamicsThreshold() 72 | { 73 | _POPPropertyAnimationState::updatedDynamicsThreshold(); 74 | if (NULL != solver) { 75 | solver->setThreshold(dynamicsThreshold); 76 | } 77 | } 78 | 79 | void updatedBouncinessAndSpeed() { 80 | [POPSpringAnimation convertBounciness:springBounciness speed:springSpeed toTension:&dynamicsTension friction:&dynamicsFriction mass:&dynamicsMass]; 81 | updatedDynamics(); 82 | } 83 | 84 | bool advance(CFTimeInterval time, CFTimeInterval dt, id obj) { 85 | // advance past not yet initialized animations 86 | if (NULL == currentVec) { 87 | return false; 88 | } 89 | 90 | CFTimeInterval localTime = time - startTime; 91 | 92 | Vector4d value = vector4d(currentVec); 93 | Vector4d toValue = vector4d(toVec); 94 | Vector4d velocity = vector4d(velocityVec); 95 | 96 | SSState4d state; 97 | state.p = toValue - value; 98 | 99 | // the solver assumes a spring of size zero 100 | // flip the velocity from user perspective to solver perspective 101 | state.v = velocity * -1; 102 | 103 | solver->advance(state, localTime, dt); 104 | value = toValue - state.p; 105 | 106 | // flip velocity back to user perspective 107 | velocity = state.v * -1; 108 | 109 | *currentVec = value; 110 | 111 | if (velocityVec) { 112 | *velocityVec = velocity; 113 | } 114 | 115 | clampCurrentValue(); 116 | 117 | return true; 118 | } 119 | 120 | virtual void reset(bool all) { 121 | _POPPropertyAnimationState::reset(all); 122 | 123 | if (solver) { 124 | solver->setConstants(dynamicsTension, dynamicsFriction, dynamicsMass); 125 | solver->reset(); 126 | } 127 | } 128 | }; 129 | 130 | typedef struct _POPSpringAnimationState POPSpringAnimationState; 131 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/POPSpringSolver.h: -------------------------------------------------------------------------------- 1 | /** 2 | Copyright (c) 2014-present, Facebook, Inc. 3 | All rights reserved. 4 | 5 | This source code is licensed under the BSD-style license found in the 6 | LICENSE file in the root directory of this source tree. An additional grant 7 | of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "POPVector.h" 13 | 14 | namespace POP { 15 | 16 | template 17 | struct SSState 18 | { 19 | T p; 20 | T v; 21 | }; 22 | 23 | template 24 | struct SSDerivative 25 | { 26 | T dp; 27 | T dv; 28 | }; 29 | 30 | typedef SSState SSState4d; 31 | typedef SSDerivative SSDerivative4d; 32 | 33 | const CFTimeInterval solverDt = 0.001f; 34 | const CFTimeInterval maxSolverDt = 30.0f; 35 | 36 | /** 37 | Templated spring solver class. 38 | */ 39 | template 40 | class SpringSolver 41 | { 42 | double _k; // stiffness 43 | double _b; // dampening 44 | double _m; // mass 45 | 46 | double _tp; // threshold 47 | double _tv; // threshold velocity 48 | double _ta; // threshold acceleration 49 | 50 | CFTimeInterval _accumulatedTime; 51 | SSState _lastState; 52 | T _lastDv; 53 | bool _started; 54 | 55 | public: 56 | SpringSolver(double k, double b, double m = 1) : _k(k), _b(b), _m(m), _started(false) 57 | { 58 | _accumulatedTime = 0; 59 | _lastState.p = T::Zero(); 60 | _lastState.v = T::Zero(); 61 | _lastDv = T::Zero(); 62 | setThreshold(1.); 63 | } 64 | 65 | ~SpringSolver() 66 | { 67 | } 68 | 69 | bool started() 70 | { 71 | return _started; 72 | } 73 | 74 | void setConstants(double k, double b, double m) 75 | { 76 | _k = k; 77 | _b = b; 78 | _m = m; 79 | } 80 | 81 | void setThreshold(double t) 82 | { 83 | _tp = t / 2; // half a unit 84 | _tv = 25.0 * t; // 5 units per second, squared for comparison 85 | _ta = 625.0 * t * t; // 5 units per second squared, squared for comparison 86 | } 87 | 88 | T acceleration(const SSState &state, double t) 89 | { 90 | return state.p*(-_k/_m) - state.v*(_b/_m); 91 | } 92 | 93 | SSDerivative evaluate(const SSState &initial, double t) 94 | { 95 | SSDerivative output; 96 | output.dp = initial.v; 97 | output.dv = acceleration(initial, t); 98 | return output; 99 | } 100 | 101 | SSDerivative evaluate(const SSState &initial, double t, double dt, const SSDerivative &d) 102 | { 103 | SSState state; 104 | state.p = initial.p + d.dp*dt; 105 | state.v = initial.v + d.dv*dt; 106 | SSDerivative output; 107 | output.dp = state.v; 108 | output.dv = acceleration(state, t+dt); 109 | return output; 110 | } 111 | 112 | void integrate(SSState &state, double t, double dt) 113 | { 114 | SSDerivative a = evaluate(state, t); 115 | SSDerivative b = evaluate(state, t, dt*0.5, a); 116 | SSDerivative c = evaluate(state, t, dt*0.5, b); 117 | SSDerivative d = evaluate(state, t, dt, c); 118 | 119 | T dpdt = (a.dp + (b.dp + c.dp)*2.0 + d.dp) * (1.0/6.0); 120 | T dvdt = (a.dv + (b.dv + c.dv)*2.0 + d.dv) * (1.0/6.0); 121 | 122 | state.p = state.p + dpdt*dt; 123 | state.v = state.v + dvdt*dt; 124 | 125 | _lastDv = dvdt; 126 | } 127 | 128 | SSState interpolate(const SSState &previous, const SSState ¤t, double alpha) 129 | { 130 | SSState state; 131 | state.p = current.p*alpha + previous.p*(1-alpha); 132 | state.v = current.v*alpha + previous.v*(1-alpha); 133 | return state; 134 | } 135 | 136 | void advance(SSState &state, double t, double dt) 137 | { 138 | _started = true; 139 | 140 | if (dt > maxSolverDt) { 141 | // excessive time step, force shut down 142 | _lastDv = _lastState.v = _lastState.p = T::Zero(); 143 | } else { 144 | _accumulatedTime += dt; 145 | 146 | SSState previousState = state, currentState = state; 147 | while (_accumulatedTime >= solverDt) { 148 | previousState = currentState; 149 | this->integrate(currentState, t, solverDt); 150 | t += solverDt; 151 | _accumulatedTime -= solverDt; 152 | } 153 | CFTimeInterval alpha = _accumulatedTime / solverDt; 154 | _lastState = state = this->interpolate(previousState, currentState, alpha); 155 | } 156 | } 157 | 158 | bool hasConverged() 159 | { 160 | if (!_started) { 161 | return false; 162 | } 163 | 164 | for (size_t idx = 0; idx < _lastState.p.size(); idx++) { 165 | if (fabs(_lastState.p(idx)) >= _tp) { 166 | return false; 167 | } 168 | } 169 | 170 | return (_lastState.v.squaredNorm() < _tv) && (_lastDv.squaredNorm() < _ta); 171 | } 172 | 173 | void reset() 174 | { 175 | _accumulatedTime = 0; 176 | _lastState.p = T::Zero(); 177 | _lastState.v = T::Zero(); 178 | _lastDv = T::Zero(); 179 | _started = false; 180 | } 181 | }; 182 | 183 | /** 184 | Convenience spring solver type definitions. 185 | */ 186 | typedef SpringSolver SpringSolver2d; 187 | typedef SpringSolver SpringSolver3d; 188 | typedef SpringSolver SpringSolver4d; 189 | } 190 | 191 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/WebCore/FloatConversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Apple Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 | * its contributors may be used to endorse or promote products derived 15 | * from this software without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef FloatConversion_h 30 | #define FloatConversion_h 31 | 32 | #include 33 | 34 | namespace WebCore { 35 | 36 | template 37 | float narrowPrecisionToFloat(T); 38 | 39 | template<> 40 | inline float narrowPrecisionToFloat(double number) 41 | { 42 | return static_cast(number); 43 | } 44 | 45 | template 46 | CGFloat narrowPrecisionToCGFloat(T); 47 | 48 | template<> 49 | inline CGFloat narrowPrecisionToCGFloat(double number) 50 | { 51 | return static_cast(number); 52 | } 53 | 54 | } // namespace WebCore 55 | 56 | #endif // FloatConversion_h 57 | -------------------------------------------------------------------------------- /FreeIOT/Lib/PopMenu/pop/WebCore/UnitBezier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Apple Inc. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #ifndef UnitBezier_h 27 | #define UnitBezier_h 28 | 29 | #include 30 | 31 | namespace WebCore { 32 | 33 | struct UnitBezier { 34 | UnitBezier(double p1x, double p1y, double p2x, double p2y) 35 | { 36 | // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1). 37 | cx = 3.0 * p1x; 38 | bx = 3.0 * (p2x - p1x) - cx; 39 | ax = 1.0 - cx -bx; 40 | 41 | cy = 3.0 * p1y; 42 | by = 3.0 * (p2y - p1y) - cy; 43 | ay = 1.0 - cy - by; 44 | } 45 | 46 | double sampleCurveX(double t) 47 | { 48 | // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule. 49 | return ((ax * t + bx) * t + cx) * t; 50 | } 51 | 52 | double sampleCurveY(double t) 53 | { 54 | return ((ay * t + by) * t + cy) * t; 55 | } 56 | 57 | double sampleCurveDerivativeX(double t) 58 | { 59 | return (3.0 * ax * t + 2.0 * bx) * t + cx; 60 | } 61 | 62 | // Given an x value, find a parametric value it came from. 63 | double solveCurveX(double x, double epsilon) 64 | { 65 | double t0; 66 | double t1; 67 | double t2; 68 | double x2; 69 | double d2; 70 | int i; 71 | 72 | // First try a few iterations of Newton's method -- normally very fast. 73 | for (t2 = x, i = 0; i < 8; i++) { 74 | x2 = sampleCurveX(t2) - x; 75 | if (fabs (x2) < epsilon) 76 | return t2; 77 | d2 = sampleCurveDerivativeX(t2); 78 | if (fabs(d2) < 1e-6) 79 | break; 80 | t2 = t2 - x2 / d2; 81 | } 82 | 83 | // Fall back to the bisection method for reliability. 84 | t0 = 0.0; 85 | t1 = 1.0; 86 | t2 = x; 87 | 88 | if (t2 < t0) 89 | return t0; 90 | if (t2 > t1) 91 | return t1; 92 | 93 | while (t0 < t1) { 94 | x2 = sampleCurveX(t2); 95 | if (fabs(x2 - x) < epsilon) 96 | return t2; 97 | if (x > x2) 98 | t0 = t2; 99 | else 100 | t1 = t2; 101 | t2 = (t1 - t0) * .5 + t0; 102 | } 103 | 104 | // Failure. 105 | return t2; 106 | } 107 | 108 | double solve(double x, double epsilon) 109 | { 110 | return sampleCurveY(solveCurveX(x, epsilon)); 111 | } 112 | 113 | private: 114 | double ax; 115 | double bx; 116 | double cx; 117 | 118 | double ay; 119 | double by; 120 | double cy; 121 | }; 122 | } 123 | #endif 124 | -------------------------------------------------------------------------------- /FreeIOT/Lib/RESideMenu/RECommonFunctions.h: -------------------------------------------------------------------------------- 1 | // 2 | // RECommonFunctions.h 3 | // RESideMenu 4 | // 5 | // Copyright (c) 2013-2014 Roman Efimov (https://github.com/romaonthego) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | #import 27 | 28 | 29 | #ifndef REUIKitIsFlatMode 30 | #define REUIKitIsFlatMode() RESideMenuUIKitIsFlatMode() 31 | #endif 32 | 33 | #ifndef kCFCoreFoundationVersionNumber_iOS_6_1 34 | #define kCFCoreFoundationVersionNumber_iOS_6_1 793.00 35 | #endif 36 | 37 | #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1 38 | #define IF_IOS7_OR_GREATER(...) \ 39 | if (kCFCoreFoundationVersionNumber > kCFCoreFoundationVersionNumber_iOS_6_1) \ 40 | { \ 41 | __VA_ARGS__ \ 42 | } 43 | #else 44 | #define IF_IOS7_OR_GREATER(...) 45 | #endif 46 | 47 | BOOL RESideMenuUIKitIsFlatMode(void); -------------------------------------------------------------------------------- /FreeIOT/Lib/RESideMenu/RECommonFunctions.m: -------------------------------------------------------------------------------- 1 | // 2 | // RECommonFunctions.m 3 | // RESideMenu 4 | // 5 | // Copyright (c) 2013-2014 Roman Efimov (https://github.com/romaonthego) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | #import "RECommonFunctions.h" 27 | #import 28 | 29 | BOOL RESideMenuUIKitIsFlatMode(void) 30 | { 31 | static BOOL isUIKitFlatMode = NO; 32 | static dispatch_once_t onceToken; 33 | dispatch_once(&onceToken, ^{ 34 | if (floor(NSFoundationVersionNumber) > 993.0) { 35 | // If your app is running in legacy mode, tintColor will be nil - else it must be set to some color. 36 | if (UIApplication.sharedApplication.keyWindow) { 37 | isUIKitFlatMode = [UIApplication.sharedApplication.delegate.window performSelector:@selector(tintColor)] != nil; 38 | } else { 39 | // Possible that we're called early on (e.g. when used in a Storyboard). Adapt and use a temporary window. 40 | isUIKitFlatMode = [[UIWindow new] performSelector:@selector(tintColor)] != nil; 41 | } 42 | } 43 | }); 44 | return isUIKitFlatMode; 45 | } -------------------------------------------------------------------------------- /FreeIOT/Lib/RESideMenu/RESideMenu.h: -------------------------------------------------------------------------------- 1 | // 2 | // REFrostedViewController.h 3 | // RESideMenu 4 | // 5 | // Copyright (c) 2013-2014 Roman Efimov (https://github.com/romaonthego) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | #import 27 | #import "UIViewController+RESideMenu.h" 28 | 29 | #ifndef IBInspectable 30 | #define IBInspectable 31 | #endif 32 | 33 | @protocol RESideMenuDelegate; 34 | 35 | @interface RESideMenu : UIViewController 36 | 37 | #if __IPHONE_8_0 38 | @property (strong, readwrite, nonatomic) IBInspectable NSString *contentViewStoryboardID; 39 | @property (strong, readwrite, nonatomic) IBInspectable NSString *leftMenuViewStoryboardID; 40 | @property (strong, readwrite, nonatomic) IBInspectable NSString *rightMenuViewStoryboardID; 41 | #endif 42 | 43 | @property (strong, readwrite, nonatomic) UIViewController *contentViewController; 44 | @property (strong, readwrite, nonatomic) UIViewController *leftMenuViewController; 45 | @property (strong, readwrite, nonatomic) UIViewController *rightMenuViewController; 46 | @property (weak, readwrite, nonatomic) id delegate; 47 | 48 | @property (assign, readwrite, nonatomic) NSTimeInterval animationDuration; 49 | @property (strong, readwrite, nonatomic) UIImage *backgroundImage; 50 | @property (assign, readwrite, nonatomic) BOOL panGestureEnabled; 51 | @property (assign, readwrite, nonatomic) BOOL panFromEdge; 52 | @property (assign, readwrite, nonatomic) NSUInteger panMinimumOpenThreshold; 53 | @property (assign, readwrite, nonatomic) IBInspectable BOOL interactivePopGestureRecognizerEnabled; 54 | @property (assign, readwrite, nonatomic) IBInspectable BOOL fadeMenuView; 55 | @property (assign, readwrite, nonatomic) IBInspectable BOOL scaleContentView; 56 | @property (assign, readwrite, nonatomic) IBInspectable BOOL scaleBackgroundImageView; 57 | @property (assign, readwrite, nonatomic) IBInspectable BOOL scaleMenuView; 58 | @property (assign, readwrite, nonatomic) IBInspectable BOOL contentViewShadowEnabled; 59 | @property (strong, readwrite, nonatomic) IBInspectable UIColor *contentViewShadowColor; 60 | @property (assign, readwrite, nonatomic) IBInspectable CGSize contentViewShadowOffset; 61 | @property (assign, readwrite, nonatomic) IBInspectable CGFloat contentViewShadowOpacity; 62 | @property (assign, readwrite, nonatomic) IBInspectable CGFloat contentViewShadowRadius; 63 | @property (assign, readwrite, nonatomic) IBInspectable CGFloat contentViewFadeOutAlpha; 64 | @property (assign, readwrite, nonatomic) IBInspectable CGFloat contentViewScaleValue; 65 | @property (assign, readwrite, nonatomic) IBInspectable CGFloat contentViewInLandscapeOffsetCenterX; 66 | @property (assign, readwrite, nonatomic) IBInspectable CGFloat contentViewInPortraitOffsetCenterX; 67 | @property (assign, readwrite, nonatomic) IBInspectable CGFloat parallaxMenuMinimumRelativeValue; 68 | @property (assign, readwrite, nonatomic) IBInspectable CGFloat parallaxMenuMaximumRelativeValue; 69 | @property (assign, readwrite, nonatomic) IBInspectable CGFloat parallaxContentMinimumRelativeValue; 70 | @property (assign, readwrite, nonatomic) IBInspectable CGFloat parallaxContentMaximumRelativeValue; 71 | @property (assign, readwrite, nonatomic) CGAffineTransform menuViewControllerTransformation; 72 | @property (assign, readwrite, nonatomic) IBInspectable BOOL parallaxEnabled; 73 | @property (assign, readwrite, nonatomic) IBInspectable BOOL bouncesHorizontally; 74 | @property (assign, readwrite, nonatomic) UIStatusBarStyle menuPreferredStatusBarStyle; 75 | @property (assign, readwrite, nonatomic) IBInspectable BOOL menuPrefersStatusBarHidden; 76 | 77 | - (id)initWithContentViewController:(UIViewController *)contentViewController 78 | leftMenuViewController:(UIViewController *)leftMenuViewController 79 | rightMenuViewController:(UIViewController *)rightMenuViewController; 80 | - (void)presentLeftMenuViewController; 81 | - (void)presentRightMenuViewController; 82 | - (void)hideMenuViewController; 83 | - (void)setContentViewController:(UIViewController *)contentViewController animated:(BOOL)animated; 84 | 85 | @end 86 | 87 | @protocol RESideMenuDelegate 88 | 89 | @optional 90 | - (void)sideMenu:(RESideMenu *)sideMenu didRecognizePanGesture:(UIPanGestureRecognizer *)recognizer; 91 | - (void)sideMenu:(RESideMenu *)sideMenu willShowMenuViewController:(UIViewController *)menuViewController; 92 | - (void)sideMenu:(RESideMenu *)sideMenu didShowMenuViewController:(UIViewController *)menuViewController; 93 | - (void)sideMenu:(RESideMenu *)sideMenu willHideMenuViewController:(UIViewController *)menuViewController; 94 | - (void)sideMenu:(RESideMenu *)sideMenu didHideMenuViewController:(UIViewController *)menuViewController; 95 | 96 | @end 97 | -------------------------------------------------------------------------------- /FreeIOT/Lib/RESideMenu/UIViewController+RESideMenu.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+RESideMenu.h 3 | // RESideMenu 4 | // 5 | // Copyright (c) 2013-2014 Roman Efimov (https://github.com/romaonthego) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | #import 27 | 28 | @class RESideMenu; 29 | 30 | @interface UIViewController (RESideMenu) 31 | 32 | @property (strong, readonly, nonatomic) RESideMenu *sideMenuViewController; 33 | 34 | // IB Action Helper methods 35 | 36 | - (IBAction)presentLeftMenuViewController:(id)sender; 37 | - (IBAction)presentRightMenuViewController:(id)sender; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /FreeIOT/Lib/RESideMenu/UIViewController+RESideMenu.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+RESideMenu.m 3 | // RESideMenu 4 | // 5 | // Copyright (c) 2013-2014 Roman Efimov (https://github.com/romaonthego) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | #import "UIViewController+RESideMenu.h" 27 | #import "RESideMenu.h" 28 | 29 | @implementation UIViewController (RESideMenu) 30 | 31 | - (RESideMenu *)sideMenuViewController 32 | { 33 | UIViewController *iter = self.parentViewController; 34 | while (iter) { 35 | if ([iter isKindOfClass:[RESideMenu class]]) { 36 | return (RESideMenu *)iter; 37 | } else if (iter.parentViewController && iter.parentViewController != iter) { 38 | iter = iter.parentViewController; 39 | } else { 40 | iter = nil; 41 | } 42 | } 43 | return nil; 44 | } 45 | 46 | #pragma mark - 47 | #pragma mark IB Action Helper methods 48 | 49 | - (IBAction)presentLeftMenuViewController:(id)sender 50 | { 51 | [self.sideMenuViewController presentLeftMenuViewController]; 52 | } 53 | 54 | - (IBAction)presentRightMenuViewController:(id)sender 55 | { 56 | [self.sideMenuViewController presentRightMenuViewController]; 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /FreeIOT/Lib/WebViewJavascriptBridge.h: -------------------------------------------------------------------------------- 1 | // 2 | // WebViewJavascriptBridge.h 3 | // ExampleApp-iOS 4 | // 5 | // Created by Marcus Westin on 6/14/13. 6 | // Copyright (c) 2013 Marcus Westin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #define kCustomProtocolScheme @"pando" //@"wvjbscheme" 12 | #define kQueueHasMessage @"invoke" //"@"__WVJB_QUEUE_MESSAGE__" 13 | 14 | 15 | #import 16 | 17 | @protocol WebViewJSBridgeDelegate 18 | 19 | @required 20 | 21 | - (void)WebViewJSBridge:(id)bridge handleCostumProtocol:(NSURL *)url; 22 | 23 | @end 24 | 25 | #define WVJB_PLATFORM_IOS 26 | #define WVJB_WEBVIEW_TYPE UIWebView 27 | #define WVJB_WEBVIEW_DELEGATE_TYPE NSObject 28 | 29 | 30 | typedef void (^WVJBResponseCallback)(id responseData); 31 | typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback); 32 | 33 | @interface WebViewJavascriptBridge : NSObject 34 | 35 | + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView handler:(WVJBHandler)handler; 36 | + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler; 37 | + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler resourceBundle:(NSBundle*)bundle; 38 | + (void)enableLogging; 39 | 40 | - (void)send:(id)message; 41 | - (void)send:(id)message responseCallback:(WVJBResponseCallback)responseCallback; 42 | - (void)registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler; 43 | - (void)callHandler:(NSString*)handlerName; 44 | - (void)callHandler:(NSString*)handlerName data:(id)data; 45 | - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback; 46 | 47 | @end 48 | 49 | 50 | -------------------------------------------------------------------------------- /FreeIOT/PandoSdk.framework/Headers/PandoSdk.h: -------------------------------------------------------------------------------- 1 | // 2 | // PandoSdk.h 3 | // PandoSdk version 0.1.0 4 | // 5 | // Created by liming_llm on 15/3/26. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | #import 9 | 10 | @protocol PandoSdkDelegate; 11 | 12 | @interface PandoSdk : NSObject 13 | 14 | 15 | /*! 16 | * @method initWithDelegate: 17 | * 18 | * @param delegate The delegate that will receive PandoSdk events. 19 | * 20 | * @discussion The initialization call. 21 | */ 22 | - (instancetype)initWithDelegate:(id)delegate; 23 | 24 | /*! 25 | * @method configDeviceToWiFi:password:byMode: 26 | * 27 | * @param ssid The WiFi ssid you want you device to connect to. 28 | * @param password The password of the specified WiFi. 29 | * @param mode The different config method. 30 | * 31 | * @discussion Configure device with the specified WiFi ssid & password by different mode. 32 | */ 33 | - (void)configDeviceToWiFi:(NSString *)ssid password:(NSString *)password byMode:(NSString *)mode; 34 | 35 | /*! 36 | * @method stopConfig 37 | * 38 | * @discussion Stop to configure device while configuring. 39 | */ 40 | - (void)stopConfig; 41 | 42 | 43 | /*! 44 | * @method isDebugOn: 45 | * 46 | * @param isDebugOn Set YES to print debug info. 47 | * 48 | * @discussion Set YES to print debug info. 49 | */ 50 | - (void)isDebugOn:(BOOL)isDebugOn; 51 | 52 | @end 53 | 54 | 55 | 56 | /*! 57 | * @protocol PandoSdkDelegate 58 | * 59 | * @discussion The delegate of a PandoSdk object must adopt the PandoSdkDelegate protocol. The optional methods provide information about PandoSdk method. 60 | * 61 | */ 62 | @protocol PandoSdkDelegate 63 | 64 | @optional 65 | 66 | /*! 67 | * @method pandoSdk:didConfigDeviceToWiFi:deviceKey:error: 68 | * 69 | * @param pandoSdk The pandoSdk object providing configDeviceToWiFi method. 70 | * @param ssid The WiFi ssid the method configure to. 71 | * @param deviceKey The device key returned from device. 72 | * @param error If an error occurred, the cause of the failure. 73 | * 74 | * @discussion This method is invoked when a pandoSdk object ended configDeviceToWifi method. 75 | */ 76 | - (void)pandoSdk:(PandoSdk *)pandoSdk didConfigDeviceToWiFi:(NSString *)ssid deviceKey:(NSString *)deviceKey error:(NSError *)error; 77 | 78 | /*! 79 | * @method pandoSdk:didStopConfig:error: 80 | * 81 | * @param pandoSdk The pandoSdk object providing stopConfig method. 82 | * @param isStoped 83 | * @param error If an error occurred, the cause of the failure. 84 | * 85 | * @discussion This method is invoked when a pandoSdk object ended stopConfig method. 86 | */ 87 | - (void)pandoSdk:(PandoSdk *)pandoSdk didStopConfig:(BOOL)isStoped error:(NSError *)error; 88 | 89 | 90 | @end 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /FreeIOT/PandoSdk.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/PandoSdk.framework/Info.plist -------------------------------------------------------------------------------- /FreeIOT/PandoSdk.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module PandoSdk { 2 | umbrella header "PandoSdk.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /FreeIOT/PandoSdk.framework/PandoSdk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/free-iot/freeiot-ios/fc43e1cd882e50a378716b68c89e0bb642eade39/FreeIOT/PandoSdk.framework/PandoSdk -------------------------------------------------------------------------------- /FreeIOT/PandoSdk.framework/_CodeSignature/CodeResources: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | files 6 | 7 | Headers/PandoSdk.h 8 | 9 | NXd2hUfa21saobef48sG6+f5iMA= 10 | 11 | Info.plist 12 | 13 | N5r3wRYtmMJj2UdL+8/9FtuYxlQ= 14 | 15 | Modules/module.modulemap 16 | 17 | 4/QcOovdOYzssKiWeFiMa2JtnVw= 18 | 19 | 20 | files2 21 | 22 | Headers/PandoSdk.h 23 | 24 | NXd2hUfa21saobef48sG6+f5iMA= 25 | 26 | Modules/module.modulemap 27 | 28 | 4/QcOovdOYzssKiWeFiMa2JtnVw= 29 | 30 | 31 | rules 32 | 33 | ^ 34 | 35 | ^.*\.lproj/ 36 | 37 | optional 38 | 39 | weight 40 | 1000 41 | 42 | ^.*\.lproj/locversion.plist$ 43 | 44 | omit 45 | 46 | weight 47 | 1100 48 | 49 | ^version.plist$ 50 | 51 | 52 | rules2 53 | 54 | .*\.dSYM($|/) 55 | 56 | weight 57 | 11 58 | 59 | ^ 60 | 61 | weight 62 | 20 63 | 64 | ^(.*/)?\.DS_Store$ 65 | 66 | omit 67 | 68 | weight 69 | 2000 70 | 71 | ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ 72 | 73 | nested 74 | 75 | weight 76 | 10 77 | 78 | ^.* 79 | 80 | ^.*\.lproj/ 81 | 82 | optional 83 | 84 | weight 85 | 1000 86 | 87 | ^.*\.lproj/locversion.plist$ 88 | 89 | omit 90 | 91 | weight 92 | 1100 93 | 94 | ^Info\.plist$ 95 | 96 | omit 97 | 98 | weight 99 | 20 100 | 101 | ^PkgInfo$ 102 | 103 | omit 104 | 105 | weight 106 | 20 107 | 108 | ^[^/]+$ 109 | 110 | nested 111 | 112 | weight 113 | 10 114 | 115 | ^embedded\.provisionprofile$ 116 | 117 | weight 118 | 20 119 | 120 | ^version\.plist$ 121 | 122 | weight 123 | 20 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /FreeIOT/View/AddDeviceViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AddDeviceViewController.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/3/15. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AddDeviceViewController : UIViewController 12 | 13 | @property(nonatomic, retain) IBOutlet UITextField *ssidText; 14 | @property(nonatomic, retain) IBOutlet UITextField *passText; 15 | @property(nonatomic, retain) IBOutlet UIButton *bindBtn; 16 | @property(nonatomic, retain) IBOutlet UIButton *configBtn; 17 | @property(nonatomic, retain) IBOutlet UINavigationItem *barItem; 18 | @property(nonatomic, copy) NSDictionary *productInfo; 19 | @property(nonatomic, copy) NSString *accessToken; 20 | @property(copy, nonatomic) NSString *bssid; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /FreeIOT/View/ChangePassViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ChangePassViewController.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/5/3. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MBProgressHUD.h" 11 | 12 | @interface ChangePassViewController : UIViewController 13 | 14 | @property (nonatomic, retain) IBOutlet UITextField *passText; 15 | @property (nonatomic, retain) IBOutlet UITextField *freshPassText; 16 | @property (nonatomic, retain) IBOutlet UITextField *confirmText; 17 | @property (nonatomic, retain) IBOutlet UIButton *okBtn; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /FreeIOT/View/DeviceAuthViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DeviceAuthViewController.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/5/4. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DeviceAuthViewController : UIViewController 12 | 13 | @property (retain, nonatomic) IBOutlet UICollectionView *userGrid; 14 | 15 | @property (copy, nonatomic) NSString *accessToken; 16 | @property (copy, nonatomic) NSString *identifier; 17 | 18 | 19 | @property (retain, nonatomic) IBOutlet UIRefreshControl *refreshControl; 20 | 21 | @property (nonatomic, retain) IBOutlet UINavigationItem *barItem; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /FreeIOT/View/DeviceDetailViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DeviceDetailViewController.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/3/19. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DeviceDetailViewController : UIViewController 12 | 13 | @property (copy, nonatomic) NSString *accessToken; 14 | 15 | @property (copy, nonatomic) NSString *identifier; 16 | 17 | @property (copy, nonatomic) NSString *url; 18 | 19 | @property (copy, nonatomic) NSString *dtitle; 20 | 21 | @property (nonatomic, retain) IBOutlet UINavigationItem *barItem; 22 | 23 | @end 24 | 25 | #if 0 26 | typedef void (* FUNCMD)(NSDictionary *); 27 | 28 | typedef struct _functionString 29 | { 30 | char *handlerName; 31 | void (*FUNCMD) (NSDictionary *); 32 | 33 | } FunCmd; 34 | 35 | FUNCMD getCurrentStatus(NSDictionary *handle); 36 | #endif 37 | -------------------------------------------------------------------------------- /FreeIOT/View/DevicePermissionViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DevicePermissionViewController.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/3/22. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DevicePermissionViewController : UIViewController 12 | 13 | @property (retain, nonatomic) IBOutlet UIPickerView *selectView; 14 | 15 | @property (retain, nonatomic) IBOutlet UIToolbar *selectBar; 16 | 17 | @property (nonatomic, retain) IBOutlet UIButton *permitBtn; 18 | 19 | @property (nonatomic, retain) IBOutlet UITextField *usernameText; 20 | 21 | @property (nonatomic, retain) IBOutlet UITextField *permitionText; 22 | 23 | @property (copy, nonatomic) NSString *accessToken; 24 | 25 | @property (copy, nonatomic) NSString *identifier; 26 | 27 | @property (copy, nonatomic) NSString *phone; 28 | 29 | @property (nonatomic, retain) IBOutlet UINavigationItem *barItem; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /FreeIOT/View/LoginViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // LoginViewController.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/3/14. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LoginViewController : UIViewController 12 | 13 | @property (nonatomic, retain) IBOutlet UIButton *loginBtn; 14 | 15 | @property (nonatomic, retain) IBOutlet UITextField *usernameText; 16 | 17 | @property (nonatomic, retain) IBOutlet UITextField *passwordText; 18 | 19 | @property (nonatomic, retain) IBOutlet UIButton *registerBtn; 20 | 21 | @property (nonatomic, retain) IBOutlet UIButton *forgetBtn; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /FreeIOT/View/ModifyDeviceViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModifyDeviceViewController.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/5/4. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MBProgressHUD.h" 11 | 12 | @interface ModifyDeviceViewController : UIViewController 13 | 14 | @property (nonatomic, retain) IBOutlet UITextField *nameText; 15 | @property (nonatomic, retain) IBOutlet UITextField *authText; 16 | @property (retain, nonatomic) IBOutlet UIPickerView *selectView; 17 | @property (retain, nonatomic) IBOutlet UIToolbar *selectBar; 18 | @property (retain, nonatomic) IBOutlet UIButton *okBtn; 19 | @property (retain, nonatomic) NSString *identifier; 20 | @property (retain, nonatomic) NSString *name; 21 | 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /FreeIOT/View/MyDevicesViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MyDevicesViewController.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/3/14. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MyDevicesViewController : UIViewController 12 | 13 | @property (retain, nonatomic) IBOutlet UICollectionView *deviceGrid; 14 | 15 | @property (copy, nonatomic) NSString *accessToken; 16 | 17 | @property (retain, nonatomic) IBOutlet UIRefreshControl *refreshControl; 18 | 19 | @property (nonatomic, retain) IBOutlet UINavigationItem *barItem; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /FreeIOT/View/ProfileMenuViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ProfileMenuViewController.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/4/28. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "RESideMenu.h" 11 | #import "MBProgressHUD.h" 12 | 13 | @interface ProfileMenuViewController : UIViewController 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /FreeIOT/View/RegisterViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RegisterViewController.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/3/22. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RegisterViewController : UIViewController 12 | 13 | @property (nonatomic, retain) IBOutlet UIButton *authcodeBtn; 14 | 15 | @property (nonatomic, retain) IBOutlet UITextField *usernameText; 16 | 17 | @property (nonatomic, retain) IBOutlet UITextField *passwordText; 18 | 19 | @property (nonatomic, retain) IBOutlet UITextField *authcodeText; 20 | 21 | @property (nonatomic, retain) IBOutlet UIButton *registerBtn; 22 | 23 | @property (nonatomic, retain) IBOutlet UINavigationItem *barItem; 24 | 25 | @property (nonatomic, retain) NSString *titleStr; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /FreeIOT/View/RootViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // RootViewController.h 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/4/28. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "RESideMenu.h" 11 | 12 | @interface RootViewController : RESideMenu 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /FreeIOT/View/RootViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // RootViewController.m 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/4/28. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import "RootViewController.h" 10 | 11 | @interface RootViewController () 12 | 13 | @end 14 | 15 | @implementation RootViewController 16 | 17 | - (void)awakeFromNib { 18 | self.menuPreferredStatusBarStyle = UIStatusBarStyleLightContent; 19 | self.contentViewShadowColor = [UIColor blackColor]; 20 | self.contentViewShadowOffset = CGSizeMake(0, 0); 21 | self.contentViewShadowOpacity = 0.6; 22 | self.contentViewShadowRadius = 12; 23 | self.contentViewShadowEnabled = YES; 24 | 25 | self.contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"contentViewController"]; 26 | self.leftMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ProfileMenuViewController"]; 27 | self.rightMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ProfileMenuViewController"]; 28 | self.backgroundImage = [UIImage imageNamed:@"menu"]; 29 | self.delegate = self; 30 | } 31 | 32 | #pragma mark - 33 | #pragma mark RESideMenu Delegate 34 | 35 | - (void)sideMenu:(RESideMenu *)sideMenu willShowMenuViewController:(UIViewController *)menuViewController { 36 | NSLog(@"willShowMenuViewController: %@", NSStringFromClass([menuViewController class])); 37 | } 38 | 39 | - (void)sideMenu:(RESideMenu *)sideMenu didShowMenuViewController:(UIViewController *)menuViewController { 40 | NSLog(@"didShowMenuViewController: %@", NSStringFromClass([menuViewController class])); 41 | } 42 | 43 | - (void)sideMenu:(RESideMenu *)sideMenu willHideMenuViewController:(UIViewController *)menuViewController { 44 | NSLog(@"willHideMenuViewController: %@", NSStringFromClass([menuViewController class])); 45 | } 46 | 47 | - (void)sideMenu:(RESideMenu *)sideMenu didHideMenuViewController:(UIViewController *)menuViewController { 48 | NSLog(@"didHideMenuViewController: %@", NSStringFromClass([menuViewController class])); 49 | } 50 | 51 | @end 52 | 53 | -------------------------------------------------------------------------------- /FreeIOT/en.lproj/Strings.strings: -------------------------------------------------------------------------------- 1 | /* 2 | Strings.strings 3 | OutletApp 4 | 5 | Created by liming_llm on 15/4/13. 6 | Copyright (c) 2015年 liming_llm. All rights reserved. 7 | */ 8 | 9 | 10 | /* ---------------------------- view title ----------------------------------- */ 11 | 12 | "MYDEVICE_TITLE" = "My Devices"; 13 | "REGISTER_TITLE" = "Create Account"; 14 | "RESET_TITLE" = "Password Reset"; 15 | "ADDDEVICE_TITLE" = "Add"; 16 | "DEVICEAUTH_TITLE" = "Authorize"; 17 | 18 | /* ---------------------------- Login view ----------------------------------- */ 19 | "LOGIN_BTN_TITLE" = "Sign In"; 20 | "USERNAME_TEXT_PLACEHOLDER" = "E-Mail Address"; 21 | "USERNAME_TEXT_PLACEHOLDER_PHONE" = "Phone Number"; 22 | "PASSWORD_TEXT_PLACEHOLDER" = "Password"; 23 | "FORGET_BTN_TLTLE" = "Forgot?"; 24 | "SIGNUP_BTN_TITLE" = "Sign Up"; 25 | 26 | /* ---------------------------- MyDevice view ----------------------------------- */ 27 | "LEFT_BTN_TITLE" = "Sign Out"; 28 | 29 | /* ---------------------------- alert title & msg ---------------------------- */ 30 | 31 | "UNBIND_ALERT_MSG" = "After unbinding,you and your authorized users will lose the authority to operate device"; 32 | "CHANGEWIFI_ALERT_TITLE" = "no WiFi network"; 33 | "CHANGEWIFI_ALERT_MSG" = "please make your phone connect to WiFi network"; 34 | "PASSEMPTY_ALERT_MSG" = "no password,leave empty?"; 35 | "GIVEUP_ALERT_MSG" = "放弃本次配置"; 36 | "CONFIGFAIL_ALERT_MSG" = "无法完成配置,请确认:\n1.WiFi名称与密码是否输入正确;\n2.是否连接了插座发出的网络。"; 37 | "CONFIGFAIL_ALERT_TITLE" = "配置失败"; 38 | "BINDDEVICE_SUCCESS_ALERT_TITLE" = "绑定设备成功"; 39 | "BINDDEVICE_FAIL_ALERT_TITLE" = "绑定设备失败"; 40 | "DEVICESTATUS_FAIL_ALERT_TILTE" = "获取设备(%@)状态失败"; 41 | "DEVICEOFFLINE_ALERT_TITLE" = "设备不在线"; 42 | "DEVICEOFFLINE_ALERT_MSG" = "设备不在线,无法进行操作"; 43 | 44 | /* ---------------------------- common string ------------------------------- */ 45 | 46 | "STR_OK" = "确定"; 47 | "STR_CANCEL" = "取消"; 48 | "STR_CHANGE_WIFI" = "请切换WiFi网络为%@"; 49 | "STR_CONNECT_FAIL" = "连接失败"; 50 | "STR_ERROR" = "错误"; 51 | "STR_FAIL" = "失败"; 52 | "STR_SUCCESS" = "成功"; 53 | "STR_NO_RESPONSE" = "服务器没有响应"; 54 | "STR_READONLY" = "仅接收消息"; 55 | "STR_RANDW" = "操控设备并且接收消息"; 56 | "STR_DEVICEAUTH" = "Authorize"; 57 | "STR_UNBIND" = "Delete"; 58 | "STR_MODIFY" = "Modify"; 59 | "STR_GETAUTHCODE" = "发送验证码"; 60 | 61 | /* ---------------------------- error code string ---------------------------- */ 62 | 63 | "系统错误" = "系统错误"; 64 | "权限错误" = "权限错误"; 65 | "未知指令" = "未知指令"; 66 | "参数错误" = "参数错误"; 67 | "发送错误" = "发送错误"; 68 | "密码错误" = "密码错误"; 69 | "注册的电话号码已存在" = "注册的电话号码已存在"; 70 | "手机验证码过期" = "手机验证码过期"; 71 | "手机验证码错误" = "手机验证码错误"; 72 | "未知属性" = "未知属性"; 73 | "请求格式不正确" = "请求格式不正确"; 74 | "设备不在线" = "设备不在线"; 75 | "请重新登录" = "请重新登录"; 76 | "设备不存在" = "设备不存在"; 77 | "用户名无效" = "用户名无效"; 78 | "设备已经绑定" = "设备已经绑定"; -------------------------------------------------------------------------------- /FreeIOT/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // OutletApp 4 | // 5 | // Created by liming_llm on 15/3/11. 6 | // Copyright (c) 2015年 liming_llm. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /FreeIOT/zh-Hans.lproj/Strings.strings: -------------------------------------------------------------------------------- 1 | /* 2 | Strings.strings 3 | OutletApp 4 | 5 | Created by liming_llm on 15/4/13. 6 | Copyright (c) 2015年 liming_llm. All rights reserved. 7 | */ 8 | 9 | 10 | /* ---------------------------- view title ----------------------------------- */ 11 | 12 | "MYDEVICE_TITLE" = "我的设备"; 13 | "REGISTER_TITLE" = "用户注册"; 14 | "RESET_TITLE" = "重置密码"; 15 | "ADDDEVICE_TITLE" = "添加设备"; 16 | "DEVICEAUTH_TITLE" = "设备授权"; 17 | 18 | /* ---------------------------- Login view ----------------------------------- */ 19 | "LOGIN_BTN_TITLE" = "登 录"; 20 | "USERNAME_TEXT_PLACEHOLDER" = "请输入电子邮件"; 21 | "USERNAME_TEXT_PLACEHOLDER_PHONE" = "请输入电话号码"; 22 | "PASSWORD_TEXT_PLACEHOLDER" = "请输入密码"; 23 | "FORGET_BTN_TLTLE" = "忘记密码?"; 24 | "SIGNUP_BTN_TITLE" = "用户注册"; 25 | 26 | /* ---------------------------- MyDevice view ----------------------------------- */ 27 | "LEFT_BTN_TITLE" = "登出"; 28 | 29 | /* ---------------------------- alert title & msg ---------------------------- */ 30 | 31 | "UNBIND_ALERT_MSG" = "解除绑定之后,您和您授权的用户都将失去操作权限"; 32 | "CHANGEWIFI_ALERT_TITLE" = "请接入WiFi网络"; 33 | "CHANGEWIFI_ALERT_MSG" = "当前手机未接入WiFi网络,请接入能够连接互联网的WiFi网络"; 34 | "PASSEMPTY_ALERT_MSG" = "您没有输入密码,确认WiFi网络无密码?"; 35 | "GIVEUP_ALERT_MSG" = "放弃本次配置"; 36 | "CONFIGFAIL_ALERT_MSG" = "无法完成配置,请确认:\n1.WiFi名称与密码是否输入正确;\n2.是否连接了插座发出的网络。"; 37 | "CONFIGFAIL_ALERT_TITLE" = "配置失败"; 38 | "BINDDEVICE_SUCCESS_ALERT_TITLE" = "绑定设备成功"; 39 | "BINDDEVICE_FAIL_ALERT_TITLE" = "绑定设备失败"; 40 | "DEVICESTATUS_FAIL_ALERT_TILTE" = "获取设备(%@)状态失败"; 41 | "DEVICEOFFLINE_ALERT_TITLE" = "设备不在线"; 42 | "DEVICEOFFLINE_ALERT_MSG" = "设备不在线,无法进行操作"; 43 | 44 | /* ---------------------------- common string ------------------------------- */ 45 | 46 | "STR_OK" = "确定"; 47 | "STR_CANCEL" = "取消"; 48 | "STR_CHANGE_WIFI" = "请切换WiFi网络为%@"; 49 | "STR_CONNECT_FAIL" = "连接失败"; 50 | "STR_ERROR" = "错误"; 51 | "STR_FAIL" = "失败"; 52 | "STR_SUCCESS" = "成功"; 53 | "STR_NO_RESPONSE" = "服务器没有响应"; 54 | "STR_READONLY" = "仅接收消息"; 55 | "STR_RANDW" = "操控设备并且接收消息"; 56 | "STR_DEVICEAUTH" = "设备授权"; 57 | "STR_UNBIND" = "解除绑定"; 58 | "STR_MODIFY" = "修改信息"; 59 | "STR_GETAUTHCODE" = "发送验证码"; 60 | 61 | /* ---------------------------- error code string ---------------------------- */ 62 | 63 | "系统错误" = "系统错误"; 64 | "权限错误" = "权限错误"; 65 | "未知指令" = "未知指令"; 66 | "参数错误" = "参数错误"; 67 | "发送错误" = "发送错误"; 68 | "密码错误" = "密码错误"; 69 | "注册的电话号码已存在" = "注册的电话号码已存在"; 70 | "手机验证码过期" = "手机验证码过期"; 71 | "手机验证码错误" = "手机验证码错误"; 72 | "未知属性" = "未知属性"; 73 | "请求格式不正确" = "请求格式不正确"; 74 | "设备不在线" = "设备不在线"; 75 | "请重新登录" = "请重新登录"; 76 | "设备不存在" = "设备不存在"; 77 | "用户名无效" = "用户名无效"; 78 | "设备已经绑定" = "设备已经绑定"; 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 PandoCloud 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # freeiot-ios 2 | FreeIOT is a open application to interact with multifarious IOT devices. 3 | --------------------------------------------------------------------------------