From 068ac557a3e00272497338ca247d6540c93e08a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20Kn=C3=B6chel?= Date: Sun, 4 Feb 2024 10:12:29 +0100 Subject: [PATCH] chore: fine tune api props, add docs --- apidoc/Titanium/UI/ImageView.yml | 22 ++++++++++++++++++++++ iphone/Classes/TiSymbolEffectManager.h | 12 ++++++------ iphone/Classes/TiSymbolEffectManager.m | 22 ++++++++++++++-------- iphone/Classes/TiUIImageView.m | 3 +-- 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/apidoc/Titanium/UI/ImageView.yml b/apidoc/Titanium/UI/ImageView.yml index 462baa48608..62ed295d53d 100644 --- a/apidoc/Titanium/UI/ImageView.yml +++ b/apidoc/Titanium/UI/ImageView.yml @@ -70,6 +70,28 @@ methods: platforms: [android, iphone, ipad, macos] returns: type: Titanium.Blob + + - name: addSymbolEffect + summary: Adds a symbol effect to the image view with specified options, animation, and callback. + platforms: [iphone, ipad, macos] + since: "12.4.0" + osver: { ios: { min: "17.0" } } + parameters: + - name: symbolEffect + summary: The symbol effect to add. + description: One of `pulse`, `bounce`, `appear`, `disappear`, `variableColor` or `scale`. + type: String + - name: options + summary: The options for the symbol effect. + description: One of `repeating`, `nonRepeating`, `repeatCount` or `speed`. + type: String + - name: animated + summary: A Boolean value that indicates whether to animate the addition of a `scale`, `appear`, or `disappear` effect. + type: Boolean + default: false + - name: callback + summary: A callback the system calls after the effect’s addition is complete. + type: Callback events: - name: change diff --git a/iphone/Classes/TiSymbolEffectManager.h b/iphone/Classes/TiSymbolEffectManager.h index ff089291dd9..a22d19f829f 100644 --- a/iphone/Classes/TiSymbolEffectManager.h +++ b/iphone/Classes/TiSymbolEffectManager.h @@ -1,9 +1,9 @@ -// -// TiSymbolEffectManager.h -// Titanium -// -// Created by Hans Knöchel on 03.02.24. -// +/** + * Titanium SDK + * Copyright TiDev, Inc. 04/07/2022-Present. All Rights Reserved. + * Licensed under the terms of the Apache Public License + * Please see the LICENSE included with this distribution for details. + */ #import diff --git a/iphone/Classes/TiSymbolEffectManager.m b/iphone/Classes/TiSymbolEffectManager.m index e9155c3e6a4..c898f18cd36 100644 --- a/iphone/Classes/TiSymbolEffectManager.m +++ b/iphone/Classes/TiSymbolEffectManager.m @@ -1,9 +1,9 @@ -// -// TiSymbolEffectManager.m -// Titanium -// -// Created by Hans Knöchel on 03.02.24. -// +/** + * Titanium SDK + * Copyright TiDev, Inc. 04/07/2022-Present. All Rights Reserved. + * Licensed under the terms of the Apache Public License + * Please see the LICENSE included with this distribution for details. + */ #import "TiSymbolEffectManager.h" #import @@ -30,9 +30,13 @@ - (NSSymbolEffect *)symbolEffect return NSSymbolAppearEffect.effect; } else if ([symbolEffectString isEqualToString:@"disappear"]) { return NSSymbolDisappearEffect.effect; + } else if ([symbolEffectString isEqualToString:@"variableColor"]) { + return NSSymbolVariableColorEffect.effect; + } else if ([symbolEffectString isEqualToString:@"scale"]) { + return NSSymbolScaleEffect.effect; } - @throw [NSException exceptionWithName:@"io.tidev.titanium-sdk" reason:@"Invalid symbol effect provided!" userInfo:nil]; + @throw [NSException exceptionWithName:@"io.tidev.titanium-sdk" reason:@"Invalid symbol effect provided" userInfo:nil]; } - (NSSymbolEffectOptions *)symbolEffectOptions @@ -44,7 +48,9 @@ - (NSSymbolEffectOptions *)symbolEffectOptions } else if ([TiUtils boolValue:@"nonRepeating" properties:symbolEffectOptions def:NO]) { return [NSSymbolEffectOptions optionsWithNonRepeating]; } else if ([TiUtils intValue:@"repeatCount" properties:symbolEffectOptions def:0] > 0) { - return [NSSymbolEffectOptions optionsWithRepeatCount:[TiUtils intValue:@"repeatCount" properties:symbolEffectOptions def:0]]; + return [NSSymbolEffectOptions optionsWithRepeatCount:[TiUtils intValue:@"repeatCount" properties:symbolEffectOptions def:1]]; + } else if ([TiUtils doubleValue:@"speed" properties:symbolEffectOptions def:0] > 0) { + return [NSSymbolEffectOptions optionsWithSpeed:[TiUtils doubleValue:@"speed" properties:symbolEffectOptions def:1.0]]; } return [NSSymbolEffectOptions options]; diff --git a/iphone/Classes/TiUIImageView.m b/iphone/Classes/TiUIImageView.m index ef77be4613a..81b1b4c832a 100644 --- a/iphone/Classes/TiUIImageView.m +++ b/iphone/Classes/TiUIImageView.m @@ -688,7 +688,6 @@ - (void)setTintColor_:(id)value - (void)addSymbolEffect:(NSDictionary *)args { - NSString *symbolEffect = [TiUtils stringValue:@"symbolEffect"]; BOOL animated = [TiUtils boolValue:@"animated" properties:args def:NO]; KrollCallback *callback = [args valueForKey:@"callback"]; @@ -700,7 +699,7 @@ - (void)addSymbolEffect:(NSDictionary *)args animated:animated completion:^(UISymbolEffectCompletionContext *_Nonnull context) { if (callback != nil) { - // [callback call:@[@{ @"finished": @(context.isFinished) }] thisObject:self]; + [callback call:@[ @{@"finished" : @(context.isFinished)} ] thisObject:self.proxy]; } }]; } else {