Skip to content

Commit

Permalink
chore: fine tune api props, add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Feb 4, 2024
1 parent f642558 commit 068ac55
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 16 deletions.
22 changes: 22 additions & 0 deletions apidoc/Titanium/UI/ImageView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions iphone/Classes/TiSymbolEffectManager.h
Original file line number Diff line number Diff line change
@@ -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 <Foundation/Foundation.h>

Expand Down
22 changes: 14 additions & 8 deletions iphone/Classes/TiSymbolEffectManager.m
Original file line number Diff line number Diff line change
@@ -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 <TitaniumKit/TiUtils.h>
Expand All @@ -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
Expand All @@ -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];
Expand Down
3 changes: 1 addition & 2 deletions iphone/Classes/TiUIImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"];

Expand All @@ -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 {
Expand Down

0 comments on commit 068ac55

Please sign in to comment.