Skip to content

Commit

Permalink
refactor: switch twitter settings cell to use link cell instead
Browse files Browse the repository at this point in the history
  • Loading branch information
SoCuul committed May 14, 2024
1 parent 820d227 commit dffcbad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
3 changes: 1 addition & 2 deletions src/Controllers/SettingsViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ typedef NS_ENUM(NSInteger, DynamicSpecifierOperatorType) {
- (PSSpecifier *)newSectionWithTitle:(NSString *)header footer:(NSString *)footer;
- (PSSpecifier *)newSwitchCellWithTitle:(NSString *)titleText detailTitle:(NSString *)detailText key:(NSString *)keyText defaultValue:(BOOL)defValue changeAction:(SEL)changeAction;
- (PSSpecifier *)newButtonCellWithTitle:(NSString *)titleText detailTitle:(NSString *)detailText dynamicRule:(NSString *)rule action:(SEL)action;
- (PSSpecifier *)newHBLinkCellWithTitle:(NSString *)titleText detailTitle:(NSString *)detailText url:(NSString *)url;
- (PSSpecifier *)newHBTwitterCellWithTitle:(NSString *)titleText twitterUsername:(NSString *)user customAvatarURL:(NSString *)avatarURL;
- (PSSpecifier *)newLinkCellWithTitle:(NSString *)titleText detailTitle:(NSString *)detailText url:(NSString *)url iconURL:(NSString *)iconURL;
- (void)reloadSpecifiers;
- (void)collectDynamicSpecifiersFromArray:(NSArray *)array;
- (BOOL)shouldHideSpecifier:(PSSpecifier *)specifier;
Expand Down
37 changes: 15 additions & 22 deletions src/Controllers/SettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,22 @@ - (PSSpecifier *)newButtonCellWithTitle:(NSString *)titleText detailTitle:(NSStr
}

// Pref Link Cell
- (PSSpecifier *)newHBLinkCellWithTitle:(NSString *)titleText detailTitle:(NSString *)detailText url:(NSString *)url {
PSSpecifier *HBLinkCell = [PSSpecifier preferenceSpecifierNamed:titleText target:self set:@selector(setPreferenceValue:specifier:) get:@selector(readPreferenceValue:) detail:nil cell:PSButtonCell edit:nil];
- (PSSpecifier *)newLinkCellWithTitle:(NSString *)titleText detailTitle:(NSString *)detailText url:(NSString *)url iconURL:(NSString *)iconURL {
PSSpecifier *LinkCell = [PSSpecifier preferenceSpecifierNamed:titleText target:self set:@selector(setPreferenceValue:specifier:) get:@selector(readPreferenceValue:) detail:nil cell:PSButtonCell edit:nil];

[HBLinkCell setButtonAction:@selector(hb_openURL:)];
[HBLinkCell setProperty:HBLinkTableCell.class forKey:@"cellClass"];
[HBLinkCell setProperty:url forKey:@"url"];
[LinkCell setButtonAction:@selector(hb_openURL:)];
[LinkCell setProperty:HBLinkTableCell.class forKey:@"cellClass"];
[LinkCell setProperty:url forKey:@"url"];
if (detailText != nil) {
[HBLinkCell setProperty:detailText forKey:@"subtitle"];
[LinkCell setProperty:detailText forKey:@"subtitle"];
}
return HBLinkCell;
}

// Pref Twitter Cell
- (PSSpecifier *)newHBTwitterCellWithTitle:(NSString *)titleText twitterUsername:(NSString *)user customAvatarURL:(NSString *)avatarURL {
PSSpecifier *TwitterCell = [PSSpecifier preferenceSpecifierNamed:titleText target:self set:@selector(setPreferenceValue:specifier:) get:@selector(readPreferenceValue:) detail:nil cell:1 edit:nil];

[TwitterCell setButtonAction:@selector(hb_openURL:)];
[TwitterCell setProperty:HBTwitterCell.class forKey:@"cellClass"];
[TwitterCell setProperty:user forKey:@"user"];
[TwitterCell setProperty:@YES forKey:@"big"];
[TwitterCell setProperty:@56 forKey:@"height"];
[TwitterCell setProperty:avatarURL forKey:@"iconURL"];
return TwitterCell;
if (iconURL != nil) {
[LinkCell setProperty:iconURL forKey:@"iconURL"];
[LinkCell setProperty:@YES forKey:@"iconCircular"];
[LinkCell setProperty:@YES forKey:@"big"];
[LinkCell setProperty:@56 forKey:@"height"];
}
return LinkCell;
}

// Tweak settings
Expand Down Expand Up @@ -145,8 +138,8 @@ - (NSArray *)specifiers {

// Section 8: Credits
[self newSectionWithTitle:@"Credits" footer:[NSString stringWithFormat:@"SCInsta %@", SCIVersionString]],
[self newHBTwitterCellWithTitle:@"Developer" twitterUsername:@"SoVeryCuul" customAvatarURL:@"https://unavatar.io/twitter/SoVeryCuul"],
[self newHBLinkCellWithTitle:@"View Repo" detailTitle:@"View the tweak's source code on GitHub" url:@"https://github.com/SoCuul/SCInsta"]
[self newLinkCellWithTitle:@"Developer" detailTitle:@"SoCuul" url:@"https://socuul.dev" iconURL:@"https://i.imgur.com/WSFMSok.png"],
[self newLinkCellWithTitle:@"View Repo" detailTitle:@"View the tweak's source code on GitHub" url:@"https://github.com/SoCuul/SCInsta" iconURL:nil]
]];

[self collectDynamicSpecifiersFromArray:_specifiers];
Expand Down

0 comments on commit dffcbad

Please sign in to comment.