-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ios): add iOS 17+ symbol effects (#13982)
* feat: add symbol effects * chore: add version guards * chore: fine tune api props, add docs * fix: merge description in summary
- Loading branch information
1 parent
a852835
commit 84ccadb
Showing
7 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* 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> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
API_AVAILABLE(ios(17)) | ||
@interface TiSymbolEffectManager : NSObject | ||
|
||
- (instancetype)initWithConfiguration:(NSDictionary *)configuration; | ||
|
||
@property (nonatomic, strong) NSDictionary *configuration; | ||
@property (nonatomic, strong) NSSymbolEffect *symbolEffect; | ||
@property (nonatomic, strong) NSSymbolEffectOptions *symbolEffectOptions; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* 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> | ||
|
||
@implementation TiSymbolEffectManager | ||
|
||
- (instancetype)initWithConfiguration:(NSDictionary *)configuration | ||
{ | ||
if (self = [self init]) { | ||
self.configuration = configuration; | ||
} | ||
return self; | ||
} | ||
|
||
- (NSSymbolEffect *)symbolEffect | ||
{ | ||
NSString *symbolEffectString = [self.configuration valueForKey:@"symbolEffect"]; | ||
|
||
if ([symbolEffectString isEqualToString:@"pulse"]) { | ||
return NSSymbolPulseEffect.effect; | ||
} else if ([symbolEffectString isEqualToString:@"bounce"]) { | ||
return NSSymbolBounceEffect.effect; | ||
} else if ([symbolEffectString isEqualToString:@"appear"]) { | ||
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]; | ||
} | ||
|
||
- (NSSymbolEffectOptions *)symbolEffectOptions | ||
{ | ||
NSDictionary *symbolEffectOptions = [self.configuration valueForKey:@"options"]; | ||
|
||
if ([TiUtils boolValue:@"repeating" properties:symbolEffectOptions def:NO]) { | ||
return [NSSymbolEffectOptions optionsWithRepeating]; | ||
} 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: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]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ | |
- (void)resume; | ||
|
||
- (void)setImage_:(id)arg; | ||
- (void)addSymbolEffect:(NSDictionary *)args; | ||
|
||
@end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters