Skip to content

Commit f69e584

Browse files
Fixed for Twitter 10-94
1 parent acd1b84 commit f69e584

21 files changed

Lines changed: 1925 additions & 1458 deletions

File tree

BHDownloadInlineButton.h

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,70 @@
55
// Created by BandarHelal on 09/04/2022.
66
//
77

8-
#import <UIKit/UIKit.h>
8+
@import UIKit;
99
#import "BHTManager.h"
1010

11+
@class T1StatusInlineActionsView; // Forward declaration instead of assuming it's imported
12+
13+
NS_ASSUME_NONNULL_BEGIN
14+
1115
@interface BHDownloadInlineButton : UIButton
1216
{
1317
NSUInteger _displayType;
1418
NSUInteger _inlineActionType;
15-
T1StatusInlineActionsView *_delegate;
19+
__weak T1StatusInlineActionsView *_delegate; // Added weak reference
1620
id _buttonAnimator;
1721
id _viewModel;
1822
}
1923

20-
+ (CGSize)buttonImageSizeUsingViewModel:(id)arg1 options:(NSUInteger)arg2 overrideButtonSize:(CGSize)arg3 account:(id)arg4;
21-
@property(retain, nonatomic) id buttonAnimator;
22-
@property(retain, nonatomic) T1StatusInlineActionsView *delegate;
23-
@property(nonatomic, assign) UIEdgeInsets hitTestEdgeInsets;
24-
@property (nonatomic, assign, readwrite) UIEdgeInsets touchInsets;
25-
@property(nonatomic) NSUInteger inlineActionType;
26-
@property(nonatomic) NSUInteger displayType;
27-
@property (nonatomic) id viewModel;
28-
- (void)setTouchInsets:(UIEdgeInsets)arg1;
29-
- (id)_t1_imageNamed:(id)arg1 fitSize:(CGSize)arg2 fillColor:(id)arg3;
30-
- (_Bool)shouldShowCount;
24+
+ (CGSize)buttonImageSizeUsingViewModel:(id)viewModel
25+
options:(NSUInteger)options
26+
overrideButtonSize:(CGSize)overrideSize
27+
account:(id)account;
28+
29+
@property (nonatomic, weak) T1StatusInlineActionsView *delegate; // Changed to weak
30+
@property (nonatomic, strong, nullable) id buttonAnimator;
31+
@property (nonatomic, assign) UIEdgeInsets hitTestEdgeInsets;
32+
@property (nonatomic, assign) UIEdgeInsets touchInsets;
33+
@property (nonatomic, assign) NSUInteger inlineActionType;
34+
@property (nonatomic, assign) NSUInteger displayType;
35+
@property (nonatomic, strong, nullable) id viewModel;
36+
37+
- (void)setTouchInsets:(UIEdgeInsets)touchInsets;
38+
- (nullable id)_t1_imageNamed:(NSString *)name
39+
fitSize:(CGSize)fitSize
40+
fillColor:(nullable id)fillColor;
41+
- (BOOL)shouldShowCount;
3142
- (double)extraWidth;
3243
- (CGFloat)trailingEdgeInset;
3344
- (NSUInteger)touchInsetPriority;
3445
- (NSUInteger)alternateInlineActionType;
3546
- (NSUInteger)visibility;
36-
- (NSString *)actionSheetTitle;
37-
- (_Bool)enabled;
38-
- (void)statusDidUpdate:(id)arg1 options:(NSUInteger)arg2 displayTextOptions:(NSUInteger)arg3 animated:(BOOL)arg4;
39-
- (void)statusDidUpdate:(id)arg1 options:(NSUInteger)arg2 displayTextOptions:(NSUInteger)arg3 animated:(BOOL)arg4 featureSwitches:(id)arg5;
40-
- (instancetype)initWithOptions:(NSUInteger)arg1 overrideSize:(id)arg2 account:(id)arg3;
41-
- (instancetype)initWithInlineActionType:(NSUInteger)arg1 options:(NSUInteger)arg2 overrideSize:(id)arg3 account:(id)arg4;
47+
- (nullable NSString *)actionSheetTitle;
48+
- (BOOL)enabled;
49+
50+
// Status update methods
51+
- (void)statusDidUpdate:(id)status
52+
options:(NSUInteger)options
53+
displayTextOptions:(NSUInteger)displayTextOptions
54+
animated:(BOOL)animated;
55+
56+
- (void)statusDidUpdate:(id)status
57+
options:(NSUInteger)options
58+
displayTextOptions:(NSUInteger)displayTextOptions
59+
animated:(BOOL)animated
60+
featureSwitches:(nullable id)featureSwitches;
61+
62+
// Initializers
63+
- (instancetype)initWithOptions:(NSUInteger)options
64+
overrideSize:(nullable id)overrideSize
65+
account:(nullable id)account;
66+
67+
- (instancetype)initWithInlineActionType:(NSUInteger)inlineActionType
68+
options:(NSUInteger)options
69+
overrideSize:(nullable id)overrideSize
70+
account:(nullable id)account;
71+
4272
@end
73+
74+
NS_ASSUME_NONNULL_END

BHDownloadInlineButton.m

Lines changed: 216 additions & 265 deletions
Large diffs are not rendered by default.

BHTManager.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ + (BOOL)customVoice {
258258
}
259259
+ (UIViewController *)BHTSettingsWithAccount:(TFNTwitterAccount *)twAccount {
260260
SettingsViewController *pref = [[SettingsViewController alloc] initWithTwitterAccount:twAccount];
261-
[pref.navigationItem setTitleView:[objc_getClass("TFNTitleView") titleViewWithTitle:@"BHTwitter" subtitle:twAccount.displayUsername]];
261+
[pref.navigationItem setTitleView:[objc_getClass("TFNTitleView") titleViewWithTitle:@"NeoFreeBird" subtitle:twAccount.displayUsername]];
262262
return pref;
263263
}
264264

CustomTabBar/BHCustomTabBarViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ - (void)getData {
9595
[[BHCustomTabBarItem alloc] initWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"CUSTOM_TAB_BAR_OPTION_5"] pageID:@"ntab"],
9696
[[BHCustomTabBarItem alloc] initWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"CUSTOM_TAB_BAR_OPTION_6"] pageID:@"messages"],
9797
[[BHCustomTabBarItem alloc] initWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"CUSTOM_TAB_BAR_OPTION_7"] pageID:@"grok"],
98-
98+
[[BHCustomTabBarItem alloc] initWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"CUSTOM_TAB_BAR_OPTION_8"] pageID:@"media"],
9999
]],
100100
[[BHCustomTabBarSection alloc] initWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"CUSTOM_TAB_BAR_SECTION_2_TITLE"] items:@[]]
101101
] mutableCopy];

SettingsViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ typedef NS_ENUM(NSInteger, DynamicSpecifierOperatorType) {
2424
@end
2525

2626
@interface BHSwitchTableCell : PSSwitchTableCell
27-
@end
27+
@end

SettingsViewController.m

Lines changed: 166 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,43 @@
55
// Created by BandarHelal
66
//
77

8+
89
#import "SettingsViewController.h"
910
#import "BHTBundle/BHTBundle.h"
1011
#import "Colours/Colours.h"
1112
#import "AppIcon/BHAppIconViewController.h"
1213
#import "ThemeColor/BHColorThemeViewController.h"
1314
#import "CustomTabBar/BHCustomTabBarViewController.h"
1415

16+
typedef NS_ENUM(NSInteger, TwitterFontWeight) {
17+
TwitterFontWeightRegular,
18+
TwitterFontWeightMedium,
19+
TwitterFontWeightSemibold,
20+
TwitterFontWeightBold
21+
};
22+
23+
typedef NS_ENUM(NSInteger, TwitterFontStyle) {
24+
TwitterFontStyleRegular,
25+
TwitterFontStyleSemibold,
26+
TwitterFontStyleBold
27+
};
28+
29+
static UIFont *TwitterChirpFont(TwitterFontStyle style) {
30+
switch (style) {
31+
case TwitterFontStyleBold:
32+
return [UIFont fontWithName:@"ChirpUIVF_wght3200000_opsz150000" size:17] ?:
33+
[UIFont systemFontOfSize:17 weight:UIFontWeightBold];
34+
35+
case TwitterFontStyleSemibold:
36+
return [UIFont fontWithName:@"ChirpUIVF_wght2BC0000_opszE0000" size:14] ?:
37+
[UIFont systemFontOfSize:14 weight:UIFontWeightSemibold];
38+
39+
case TwitterFontStyleRegular:
40+
default:
41+
return [UIFont fontWithName:@"ChirpUIVF_wght1900000_opszE0000" size:12] ?:
42+
[UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
43+
}
44+
}
1545
@interface SettingsViewController () <UIFontPickerViewControllerDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIColorPickerViewControllerDelegate>
1646
@property (nonatomic, strong) TFNTwitterAccount *twAccount;
1747
@property (nonatomic, assign) BOOL hasDynamicSpecifiers;
@@ -66,8 +96,112 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
6696
}
6797
}
6898

99+
100+
// Add this method to configure the table view appearance
101+
- (void)viewDidLoad {
102+
[super viewDidLoad];
103+
104+
105+
106+
107+
// Set the background color to match system background
108+
self.view.backgroundColor = [UIColor systemBackgroundColor];
109+
110+
// Configure the table view to blend with background
111+
self.table.backgroundColor = [UIColor systemBackgroundColor];
112+
self.table.separatorColor = [UIColor separatorColor];
113+
114+
// Remove extra separators below content
115+
self.table.tableFooterView = [UIView new];
116+
self.table.separatorStyle = UITableViewCellSeparatorStyleNone;
117+
118+
if (@available(iOS 15.0, *)) {
119+
self.table.sectionHeaderTopPadding = 8;
120+
}
121+
122+
// These ensure cells align with headers
123+
self.table.separatorInset = UIEdgeInsetsMake(0, 16, 0, 0);
124+
self.table.layoutMargins = UIEdgeInsetsMake(0, 16, 0, 16);
125+
126+
127+
}
128+
129+
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
130+
NSString *title = [self tableView:tableView titleForHeaderInSection:section];
131+
if (!title) {
132+
return nil;
133+
}
134+
135+
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 52)];
136+
137+
// Top separator - modified to extend full width
138+
UIView *topSeparator = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 0.5)];
139+
topSeparator.backgroundColor = [UIColor separatorColor];
140+
topSeparator.autoresizingMask = UIViewAutoresizingFlexibleWidth; // Ensure it stays full width
141+
[headerView addSubview:topSeparator];
142+
143+
// Header label
144+
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(16, 16, tableView.frame.size.width - 32, 28)];
145+
label.text = title;
146+
label.font = TwitterChirpFont(TwitterFontStyleBold); // 17pt bold
147+
label.textColor = [UIColor labelColor];
148+
[headerView addSubview:label];
149+
150+
return headerView;
151+
}
152+
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
153+
return 52; // Increased from 44 to accommodate larger text
154+
}
155+
156+
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
157+
NSString *footerText = [self tableView:tableView titleForFooterInSection:section];
158+
if (!footerText) {
159+
return nil;
160+
}
161+
162+
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 44)];
163+
164+
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(16, 8, tableView.frame.size.width - 32, 36)];
165+
label.text = footerText;
166+
label.font = TwitterChirpFont(TwitterFontStyleRegular); // 12pt regular
167+
label.textColor = [UIColor secondaryLabelColor];
168+
label.numberOfLines = 0;
169+
[footerView addSubview:label];
170+
171+
return footerView;
172+
}
173+
174+
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
175+
NSString *footerText = [self tableView:tableView titleForFooterInSection:section];
176+
if (!footerText) {
177+
return CGFLOAT_MIN; // Use minimal height when no footer
178+
}
179+
180+
// Calculate dynamic height
181+
CGFloat width = tableView.frame.size.width - 32;
182+
CGRect rect = [footerText boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX)
183+
options:NSStringDrawingUsesLineFragmentOrigin
184+
attributes:@{NSFontAttributeName: TwitterChirpFont(TwitterFontStyleRegular)}
185+
context:nil];
186+
187+
return ceil(rect.size.height) + 24; // Top/bottom padding
188+
}
189+
190+
// And replace with this single implementation:
191+
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
192+
// Remove any default separator insets
193+
cell.separatorInset = UIEdgeInsetsMake(0, 0, 0, CGRectGetWidth(tableView.bounds));
194+
195+
// Set cell background
196+
cell.backgroundColor = [UIColor systemBackgroundColor];
197+
198+
// Remove selection highlight if needed
199+
cell.selectionStyle = UITableViewCellSelectionStyleDefault;
200+
}
201+
202+
69203
- (UITableViewStyle)tableViewStyle {
70-
return UITableViewStyleInsetGrouped;
204+
return UITableViewStyleGrouped;
71205
}
72206

73207
- (PSSpecifier *)newSectionWithTitle:(NSString *)header footer:(NSString *)footer {
@@ -226,24 +360,22 @@ - (NSArray *)specifiers {
226360
PSSpecifier *acknowledgements = [self newButtonCellWithTitle:[[BHTBundle sharedBundle] localizedStringForKey:@"LEGAL_BUTTON_TITLE"] detailTitle:nil dynamicRule:nil action:@selector(showAcknowledgements:)];
227361

228362
// dvelopers section
363+
364+
PSSpecifier *actuallyaridan = [self newHBTwitterCellWithTitle:@"aridan" twitterUsername:@"actuallyaridan" customAvatarURL:@"https://avatars.githubusercontent.com/u/96298432?v=4"];
365+
PSSpecifier *timi2506 = [self newHBTwitterCellWithTitle:@"timi2506" twitterUsername:@"timi2506" customAvatarURL:@"https://avatars.githubusercontent.com/u/172171055?v=4"];
366+
PSSpecifier *nyathea = [self newHBTwitterCellWithTitle:@"nyathea" twitterUsername:@"nyaathea" customAvatarURL:@"https://avatars.githubusercontent.com/u/108613931?v=4"];
229367
PSSpecifier *bandarHL = [self newHBTwitterCellWithTitle:@"BandarHelal" twitterUsername:@"BandarHL" customAvatarURL:@"https://unavatar.io/twitter/BandarHL"];
230-
PSSpecifier *tipJar = [self newHBLinkCellWithTitle:@"Tip Jar" detailTitle:@"Donate Via Paypal" url:@"https://www.paypal.me/BandarHL"];
231-
PSSpecifier *buymecoffee = [self newHBLinkCellWithTitle:@"Buy Me A Coffee" detailTitle:nil url:@"https://www.buymeacoffee.com/bandarHL"];
232-
PSSpecifier *sourceCode = [self newHBLinkCellWithTitle:@"BHTwitter" detailTitle:@"Code source of BHTwitter" url:@"https://github.com/BandarHL/BHTwitter/"];
233368

234369
_specifiers = [NSMutableArray arrayWithArray:@[
235370

236371
mainSection, // 0
237-
download,
238-
hideAds,
239372
customVoice,
240373
hideTopics,
241374
hideWhoToFollow,
242375
hideTopicsToFollow,
243-
hidePremiumOffer,
244376
hideTrendVideos,
377+
hideSpace,
245378
videoLayerCaption,
246-
directSave,
247379
noHistory,
248380
bioTranslate,
249381
likeConfrim,
@@ -254,14 +386,17 @@ - (NSArray *)specifiers {
254386
disableSensitiveTweetWarnings,
255387
copyProfileInfo,
256388
tweetToImage,
257-
hideSpace,
258389
disableRTL,
259390
alwaysOpenSafari,
260391
stripTrackingParams,
261392
urlHost,
262393

263394
twitterBlueSection, // 1
264395
undoTweet,
396+
download,
397+
directSave,
398+
hideAds,
399+
hidePremiumOffer,
265400
appTheme,
266401
appIcon,
267402
customTabBarVC,
@@ -285,10 +420,10 @@ - (NSArray *)specifiers {
285420
flex,
286421

287422
developer, // 5
288-
bandarHL,
289-
tipJar,
290-
buymecoffee,
291-
sourceCode
423+
actuallyaridan,
424+
timi2506,
425+
nyathea,
426+
bandarHL
292427
]];
293428

294429
[self collectDynamicSpecifiersFromArray:_specifiers];
@@ -503,7 +638,7 @@ - (void)showURLHostSelectionViewController:(PSSpecifier *)specifier {
503638
UITableViewCell *specifierCell = [specifier propertyForKey:PSTableCellKey];
504639
PSSpecifier *selectionSpecifier = [self specifierForID:@"Select URL host"];
505640

506-
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"BHTwitter" message:@"plaese select what host you prefre" preferredStyle:UIAlertControllerStyleActionSheet];
641+
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"NeoFreeBird" message:@"URL" preferredStyle:UIAlertControllerStyleActionSheet];
507642

508643
if (alert.popoverPresentationController != nil) {
509644
CGFloat midX = CGRectGetMidX(specifierCell.frame);
@@ -612,7 +747,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
612747

613748
if ([manager fileExistsAtPath:newImgPath.path]) {
614749
[manager removeItemAtURL:newImgPath error:nil];
615-
}
750+
}
616751

617752
[manager copyItemAtURL:oldImgPath toURL:newImgPath error:nil];
618753

@@ -633,23 +768,38 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr
633768
if (self) {
634769
NSString *subTitle = [specifier.properties[@"subtitle"] copy];
635770
BOOL isBig = specifier.properties[@"big"] ? ((NSNumber *)specifier.properties[@"big"]).boolValue : NO;
771+
772+
// Get the default font size and make it bold
773+
UIFont *defaultFont = self.textLabel.font;
774+
self.textLabel.font = TwitterChirpFont(TwitterFontStyleSemibold); // 14pt semibold
775+
776+
// Keep subtitle style exactly as before
636777
self.detailTextLabel.text = subTitle;
637778
self.detailTextLabel.numberOfLines = isBig ? 0 : 1;
638779
self.detailTextLabel.textColor = [UIColor secondaryLabelColor];
780+
self.detailTextLabel.font = TwitterChirpFont(TwitterFontStyleRegular); // Match footer font
781+
self.selectionStyle = UITableViewCellSelectionStyleDefault; // or .None if you don't want selection highlight
639782
}
640783
return self;
641784
}
642-
643785
@end
644786

645787
@implementation BHSwitchTableCell
646788
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier specifier:(PSSpecifier *)specifier {
647789
if ((self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier specifier:specifier])) {
648790
NSString *subTitle = [specifier.properties[@"subtitle"] copy];
649791
BOOL isBig = specifier.properties[@"big"] ? ((NSNumber *)specifier.properties[@"big"]).boolValue : NO;
792+
793+
// Get the default font size and make it bold
794+
UIFont *defaultFont = self.textLabel.font;
795+
self.textLabel.font = TwitterChirpFont(TwitterFontStyleSemibold); // 14pt semibold
796+
797+
// Keep subtitle style exactly as before
650798
self.detailTextLabel.text = subTitle;
651799
self.detailTextLabel.numberOfLines = isBig ? 0 : 1;
652800
self.detailTextLabel.textColor = [UIColor secondaryLabelColor];
801+
self.detailTextLabel.font = TwitterChirpFont(TwitterFontStyleRegular); // Match footer font
802+
self.selectionStyle = UITableViewCellSelectionStyleDefault; // or .None if you don't want selection highlight
653803

654804
if (specifier.properties[@"switchAction"]) {
655805
UISwitch *targetSwitch = ((UISwitch *)[self control]);

0 commit comments

Comments
 (0)