From c420e27faabc4c852a6d6e3bbf44f77017875ee6 Mon Sep 17 00:00:00 2001 From: Dal Rupnik Date: Sun, 27 Sep 2015 23:54:19 +0200 Subject: [PATCH] Updated force touch display --- .../Object/Converters/ALPHAObjectConverter.m | 307 ++++++++++-------- .../Touch/Library/ALPHATouchFingerView.m | 3 +- Example/Alpha.xcodeproj/project.pbxproj | 9 + 3 files changed, 176 insertions(+), 143 deletions(-) diff --git a/Alpha/Plugins/Object/Converters/ALPHAObjectConverter.m b/Alpha/Plugins/Object/Converters/ALPHAObjectConverter.m index 2d28193..22f3e5d 100644 --- a/Alpha/Plugins/Object/Converters/ALPHAObjectConverter.m +++ b/Alpha/Plugins/Object/Converters/ALPHAObjectConverter.m @@ -24,116 +24,125 @@ @implementation ALPHAObjectConverter -- (BOOL)canConvertObject:(id)object { +- (BOOL)canConvertObject:(id)object +{ return [object isKindOfClass:[ALPHAObjectModel class]]; } -- (ALPHAScreenModel *)screenModelForObject:(ALPHAObjectModel *)object { - // - // This is an exception that we send an empty identifier. We will not reload - // the object. - // - // - ALPHATableScreenModel *model = - [[ALPHATableScreenModel alloc] initWithRequest:object.request]; - // model.title = [NSString stringWithFormat:@"Live Objects (%lu)", (unsigned - // long)totalCount]; - model.title = object.objectClass; - - model.searchBarPlaceholder = @"Filter"; - model.scopes = @[ @"No Inheritance", @"Include Inheritance" ]; - - NSMutableArray *sections = [NSMutableArray array]; - - // - // Add sections - // - - if (object.objectDescription) { - [sections addObject:[self sectionForDescriptionWithModel:object]]; - } +- (ALPHAScreenModel *)screenModelForObject:(ALPHAObjectModel *)object +{ + // + // This is an exception that we send an empty identifier. We will not reload + // the object. + // + ALPHATableScreenModel *model = [[ALPHATableScreenModel alloc] initWithRequest:object.request]; + // model.title = [NSString stringWithFormat:@"Live Objects (%lu)", (unsigned + // long)totalCount]; + model.title = object.objectClass; + + model.searchBarPlaceholder = @"Filter"; + model.scopes = @[ @"No Inheritance", @"Include Inheritance" ]; + + NSMutableArray *sections = [NSMutableArray array]; + + // + // Add sections + // + + if (object.objectDescription) + { + [sections addObject:[self sectionForDescriptionWithModel:object]]; + } - ALPHAScreenSection *section = [self sectionForObjectTypeWithModel:object]; + ALPHAScreenSection *section = [self sectionForObjectTypeWithModel:object]; - if (section) { - [sections addObject:section]; - } + if (section) + { + [sections addObject:section]; + } - [sections - addObject:[self sectionForPropertyName:@"properties" inModel:object]]; - [sections addObject:[self sectionForPropertyName:@"ivars" inModel:object]]; - [sections addObject:[self sectionForPropertyName:@"methods" inModel:object]]; - [sections - addObject:[self sectionForPropertyName:@"classMethods" inModel:object]]; - [sections - addObject:[self superclassesSectionForModel:object]]; - - if (!object.request.parameters[ALPHASearchTextParameterKey]) { - [sections addObject:[self sectionForObjectGraphWithObject:object]]; - } + [sections addObject:[self sectionForPropertyName:@"properties" inModel:object]]; + [sections addObject:[self sectionForPropertyName:@"ivars" inModel:object]]; + [sections addObject:[self sectionForPropertyName:@"methods" inModel:object]]; + [sections addObject:[self sectionForPropertyName:@"classMethods" inModel:object]]; + [sections addObject:[self superclassesSectionForModel:object]]; + + if (!object.request.parameters[ALPHASearchTextParameterKey]) + { + [sections addObject:[self sectionForObjectGraphWithObject:object]]; + } - model.sections = sections.copy; + model.sections = sections.copy; - model.expiration = 60.0; + model.expiration = 60.0; - return model; + return model; } #pragma mark - --(ALPHAScreenSection*)superclassesSectionForModel:(ALPHAObjectModel*)model{ +- (ALPHAScreenSection*)superclassesSectionForModel:(ALPHAObjectModel *)model +{ ALPHAScreenSection* section = [self sectionForPropertyName:@"superclasses" inModel:model]; - for (ALPHAScreenItem* screenItem in section.items) { + + for (ALPHAScreenItem* screenItem in section.items) + { NSString* classString = screenItem.object; Class classObject = NSClassFromString(classString); ALPHARequest* request = [ALPHARequest requestForObject:classObject]; screenItem.object = request; } + return section; } #pragma mark - Private methods -- (ALPHAScreenSection *)sectionForPropertyName:(NSString *)property inModel:(ALPHAObjectModel *)model { +- (ALPHAScreenSection *)sectionForPropertyName:(NSString *)property inModel:(ALPHAObjectModel *)model +{ ALPHAScreenSection *section = [[ALPHAScreenSection alloc] init]; NSMutableArray *items = [NSMutableArray array]; NSArray *array = [model valueForKey:property]; - section.headerText = [[property alpha_titleCaseForCamelCase] - stringByAppendingFormat:@" (%ld)", (long)array.count]; + section.headerText = [[property alpha_titleCaseForCamelCase] stringByAppendingFormat:@" (%ld)", (long)array.count]; - for (id object in array) { + for (id object in array) + { ALPHAScreenItem *item = [[ALPHAScreenItem alloc] init]; item.style = UITableViewCellStyleSubtitle; if ([object isKindOfClass:[ALPHAObjectProperty class]]) { item.title = [object description]; item.detail = [ALPHARuntimeUtility - descriptionForIvarOrPropertyValue:[(ALPHAObjectProperty *) - object value]]; - } else if ([object isKindOfClass:[ALPHAObjectIvar class]]) { + descriptionForIvarOrPropertyValue:[(ALPHAObjectProperty *)object value]]; + } + else if ([object isKindOfClass:[ALPHAObjectIvar class]]) + { item.title = [object prettyDescription]; item.detail = [ALPHARuntimeUtility descriptionForIvarOrPropertyValue:[(ALPHAObjectIvar *)object value]]; - } else if ([object isKindOfClass:[ALPHAObjectMethod class]]) { + } + else if ([object isKindOfClass:[ALPHAObjectMethod class]]) + { item.title = [object prettyDescription]; - } else { + } + else + { item.title = [object description]; } // Ignore object for some kinds of object values e.g. properties, methods, // ivars for Class objects. BOOL shouldIgnoreObject = NO; - if (model.objectIsClass && - ([object isKindOfClass:[ALPHAObjectProperty class]] || - [object isKindOfClass:[ALPHAObjectIvar class]] || - ([object isKindOfClass:[ALPHAObjectMethod class]] && - ![(ALPHAObjectMethod *)object isClassMethod]))) { + if (model.objectIsClass && ([object isKindOfClass:[ALPHAObjectProperty class]] || [object isKindOfClass:[ALPHAObjectIvar class]] || ([object isKindOfClass:[ALPHAObjectMethod class]] && ![(ALPHAObjectMethod *)object isClassMethod]))) + { shouldIgnoreObject = YES; } - if (!shouldIgnoreObject) { + + if (!shouldIgnoreObject) + { item.object = object; } @@ -145,7 +154,8 @@ - (ALPHAScreenSection *)sectionForPropertyName:(NSString *)property inModel:(ALP return section; } -- (ALPHAScreenSection *)sectionForDescriptionWithModel:(ALPHAObjectModel *)model { +- (ALPHAScreenSection *)sectionForDescriptionWithModel:(ALPHAObjectModel *)model +{ ALPHAScreenSection *section = [[ALPHAScreenSection alloc] init]; section.headerText = @"Description"; @@ -157,87 +167,96 @@ - (ALPHAScreenSection *)sectionForDescriptionWithModel:(ALPHAObjectModel *)model return section; } -- (ALPHAScreenSection *)sectionForObjectTypeWithModel:(ALPHAObjectModel *)model { - // - // If we have object content, build section from it. - // +- (ALPHAScreenSection *)sectionForObjectTypeWithModel:(ALPHAObjectModel *)model +{ + // + // If we have object content, build section from it. + // - NSMutableArray *items = [NSMutableArray array]; + NSMutableArray *items = [NSMutableArray array]; - Class class = NSClassFromString(model.objectMainSuperclass); + Class class = NSClassFromString(model.objectMainSuperclass); - ALPHAScreenSection *section = [[ALPHAScreenSection alloc] init]; + ALPHAScreenSection *section = [[ALPHAScreenSection alloc] init]; - section.headerText = [self headerStringForClass:class]; + section.headerText = [self headerStringForClass:class]; - if (model.objectContent) { - for (ALPHAObjectElement *item in model.objectContent.items) { - ALPHAScreenItem *screenItem = [[ALPHAScreenItem alloc] init]; + if (model.objectContent) + { + for (ALPHAObjectElement *item in model.objectContent.items) + { + ALPHAScreenItem *screenItem = [[ALPHAScreenItem alloc] init]; - screenItem.title = item.name; - screenItem.detail = item.objectClass; + screenItem.title = item.name; + screenItem.detail = item.objectClass; - screenItem.object = + screenItem.object = [ALPHARequest requestForObjectPointer:item.objectPointer - className:item.objectClass]; - } + className:item.objectClass]; + } - section.items = items.copy; + section.items = items.copy; - return section; - } + return section; + } - // - // This represents specific object types and can add a special section, such - // as Array, Set, View, - // Layer, etc. Equals to custom section on ALPHAObjectExplorerViewController - // - - // - // Currently handled specific Foundation objects to add shortcuts that the - // original code had. - // - UIViewController - // - UIView - // - CALayer - // - Class - // - - NSArray *shortcuts = [self shortcutsForClass:class]; - ALPHAScreenItem *liveInstancesShortcut = - [self liveInstancesShortcutForClass:NSClassFromString(model.objectClass)]; - shortcuts = [shortcuts arrayByAddingObject:liveInstancesShortcut]; - - if (shortcuts) { - [items addObjectsFromArray:shortcuts]; - } + // + // This represents specific object types and can add a special section, such + // as Array, Set, View, + // Layer, etc. Equals to custom section on ALPHAObjectExplorerViewController + // + + // + // Currently handled specific Foundation objects to add shortcuts that the + // original code had. + // - UIViewController + // - UIView + // - CALayer + // - Class + // + + NSArray *shortcuts = [self shortcutsForClass:class]; + ALPHAScreenItem *liveInstancesShortcut = [self liveInstancesShortcutForClass:NSClassFromString(model.objectClass)]; + shortcuts = [shortcuts arrayByAddingObject:liveInstancesShortcut]; + + if (shortcuts) + { + [items addObjectsFromArray:shortcuts]; + } - // - // Return section if we have a title - // + // + // Return section if we have a title + // - if (section.headerText) { - section.items = items.copy; + if (section.headerText) + { + section.items = items.copy; - return section; - } + return section; + } - return nil; + return nil; } -- (NSString *)headerStringForClass:(Class) class { - if (class == [NSObject class]) { +- (NSString *)headerStringForClass:(Class)class +{ + if (class == [NSObject class]) + { return nil; } - if (class == [NSArray class] || class == [NSMutableArray class]) { + if (class == [NSArray class] || class == [NSMutableArray class]) + { return @"Array Indices"; } - if (class == [NSDictionary class] || class == [NSMutableDictionary class]) { + if (class == [NSDictionary class] || class == [NSMutableDictionary class]) + { return @"Dictionary Objects"; } - if (class == [NSUserDefaults class]) { + if (class == [NSUserDefaults class]) + { return @"Defaults"; } @@ -245,8 +264,10 @@ - (NSString *)headerStringForClass:(Class) class { return @"Shortcuts"; } -- (NSArray *)shortcutsForClass : (Class) class { - if (class == [NSObject class] || class == NULL) { +- (NSArray *)shortcutsForClass:(Class)class +{ + if (class == [NSObject class] || class == NULL) + { return @[]; } @@ -254,7 +275,8 @@ - (NSArray *)shortcutsForClass : (Class) class { ALPHAScreenItem *item = nil; - if (class == [UIViewController class]) { + if (class == [UIViewController class]) + { item = [[ALPHAScreenItem alloc] init]; item.title = @"Push View Controller"; @@ -264,7 +286,9 @@ - (NSArray *)shortcutsForClass : (Class) class { item.title = @"@property UIView *view"; [items addObject:item]; - } else if (class == [UIView class]) { + } + else if (class == [UIView class]) + { item = [[ALPHAScreenItem alloc] init]; item.title = @"View Controller"; @@ -274,7 +298,9 @@ - (NSArray *)shortcutsForClass : (Class) class { item.title = @"Preview Image"; [items addObject:item]; - } else if (class == [CALayer class]) { + } + else if (class == [CALayer class]) + { item = [[ALPHAScreenItem alloc] init]; item.title = @"Preview Image"; @@ -284,33 +310,24 @@ - (NSArray *)shortcutsForClass : (Class) class { return items.copy; } -- (ALPHAScreenItem *)liveInstancesShortcutForClass : (Class) class { - BOOL isMeta = class_isMetaClass(class); +- (ALPHAScreenItem *)liveInstancesShortcutForClass:(Class)class +{ + //BOOL isMeta = class_isMetaClass(class); ALPHAScreenItem *item = [[ALPHAScreenItem alloc] init]; item.title = @"Live Instances"; - item.object = - [ALPHARequest requestWithIdentifier:ALPHAInstanceDataIdentifier - parameters:@{ - ALPHAInstanceDataClassNameIdentifier : - NSStringFromClass(class) - }]; + item.object = [ALPHARequest requestWithIdentifier:ALPHAInstanceDataIdentifier parameters:@{ ALPHAInstanceDataClassNameIdentifier : NSStringFromClass(class) }]; return item; } -- (ALPHAScreenSection *)sectionForObjectGraphWithObject: (ALPHAObjectModel *)object { +- (ALPHAScreenSection *)sectionForObjectGraphWithObject:(ALPHAObjectModel *)object +{ ALPHAScreenSection *section = [[ALPHAScreenSection alloc] init]; section.headerText = @"Object Graph"; ALPHAScreenItem *item = [[ALPHAScreenItem alloc] init]; item.title = @"Other objects with ivars referencing this object"; - item.object = [ALPHARequest - requestWithIdentifier:ALPHAInstanceDataIdentifier - parameters:@{ - ALPHAInstanceDataClassNameIdentifier : object.objectClass, - ALPHAInstanceDataReferenceObjectIdentifier : - object.objectPointer - }]; + item.object = [ALPHARequest requestWithIdentifier:ALPHAInstanceDataIdentifier parameters:@{ ALPHAInstanceDataClassNameIdentifier : object.objectClass, ALPHAInstanceDataReferenceObjectIdentifier : object.objectPointer }]; section.items = @[ item ]; @@ -319,12 +336,18 @@ - (ALPHAScreenSection *)sectionForObjectGraphWithObject: (ALPHAObjectModel *)obj #pragma mark - Render class -- (Class)renderClassForObject:(id)object { - if ([object isKindOfClass:[ALPHAObjectMethod class]]) { +- (Class)renderClassForObject:(id)object +{ + if ([object isKindOfClass:[ALPHAObjectMethod class]]) + { return [ALPHAMethodRendererViewController class]; - } else if ([object isKindOfClass:[ALPHAObjectProperty class]]) { + } + else if ([object isKindOfClass:[ALPHAObjectProperty class]]) + { return [ALPHAPropertyRendererViewController class]; - } else if ([object isKindOfClass:[ALPHAObjectIvar class]]) { + } + else if ([object isKindOfClass:[ALPHAObjectIvar class]]) + { return [ALPHAIvarRendererViewController class]; } diff --git a/Alpha/Plugins/Touch/Library/ALPHATouchFingerView.m b/Alpha/Plugins/Touch/Library/ALPHATouchFingerView.m index 1891936..0795982 100644 --- a/Alpha/Plugins/Touch/Library/ALPHATouchFingerView.m +++ b/Alpha/Plugins/Touch/Library/ALPHATouchFingerView.m @@ -11,6 +11,7 @@ #import "ALPHATouchFingerView.h" CGFloat const ALPHADefaultMaxFingerRadius = 22.0; +CGFloat const ALPHADefaultForceTouchScale = 0.75; @interface ALPHATouchFingerView () @@ -90,7 +91,7 @@ - (void)updateWithTouch:(UITouch *)touch self.center = point; - self.lastScale = CGPointMake(MAX(1, touch.force), MAX(1, touch.force)); + self.lastScale = CGPointMake(MAX(1, touch.force * ALPHADefaultForceTouchScale), MAX(1, touch.force * ALPHADefaultForceTouchScale)); self.transform = CGAffineTransformMakeScale(self.lastScale.x, self.lastScale.y); diff --git a/Example/Alpha.xcodeproj/project.pbxproj b/Example/Alpha.xcodeproj/project.pbxproj index ddce149..396c090 100644 --- a/Example/Alpha.xcodeproj/project.pbxproj +++ b/Example/Alpha.xcodeproj/project.pbxproj @@ -2337,6 +2337,9 @@ CreatedOnToolsVersion = 6.3.2; TestTargetID = 5356823918F3656900BAAD62; }; + 5356823918F3656900BAAD62 = { + DevelopmentTeam = 289M6XEDV4; + }; }; }; buildConfigurationList = 5356823518F3656900BAAD62 /* Build configuration list for PBXProject "Alpha" */; @@ -3031,6 +3034,8 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "UICatalog/UICatalog-Prefix.pch"; @@ -3038,6 +3043,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; PRODUCT_BUNDLE_IDENTIFIER = "com.unifiedsense.apple-samplecode.UICatalog"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; WRAPPER_EXTENSION = app; }; name = Debug; @@ -3048,6 +3054,8 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "UICatalog/UICatalog-Prefix.pch"; @@ -3055,6 +3063,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; PRODUCT_BUNDLE_IDENTIFIER = "com.unifiedsense.apple-samplecode.UICatalog"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; WRAPPER_EXTENSION = app; }; name = Release;