Skip to content

Commit 0796b5a

Browse files
committed
Introduce extension to set common UIButton style
Common style: - ICON_TINT_COLOR for Normal - ICON_TINT_COLOR_ACTIVE for Selected - No image for Highlighted - showsTouchWhenHighlighted = NO Few deviations where color shall not be adapted, like Kodi icons or the Kodi blue shuffle/repeat icons.
1 parent 2318892 commit 0796b5a

12 files changed

+113
-152
lines changed

XBMC Remote/DetailViewController.m

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -820,14 +820,12 @@ - (UITextField*)getSearchTextField:(UISearchBar*)searchBar {
820820

821821
- (void)setGridListButtonImage:(BOOL)isGridView {
822822
NSString *imgName = isGridView ? @"st_view_grid" : @"st_view_list";
823-
UIImage *image = [Utilities colorizeImage:[UIImage imageNamed:imgName] withColor:ICON_TINT_COLOR];
824-
[button6 setBackgroundImage:image forState:UIControlStateNormal];
823+
[button6 setDatabaseToolbarStyle:[UIImage imageNamed:imgName]];
825824
}
826825

827826
- (void)setSortButtonImage:(NSString*)sortOrder {
828827
NSString *imgName = [sortOrder isEqualToString:@"descending"] ? @"st_sort_desc" : @"st_sort_asc";
829-
UIImage *image = [Utilities colorizeImage:[UIImage imageNamed:imgName] withColor:ICON_TINT_COLOR];
830-
[button7 setBackgroundImage:image forState:UIControlStateNormal];
828+
[button7 setDatabaseToolbarStyle:[UIImage imageNamed:imgName]];
831829
}
832830

833831
- (void)setButtonViewContent:(int)activeTab {
@@ -3014,7 +3012,6 @@ - (void)layoutSectionView:(UIView*)albumDetailView thumbView:(UIImageView*)thumb
30143012

30153013
// Add Info button to bottom-right corner
30163014
albumInfoButton.alpha = 0.8;
3017-
albumInfoButton.showsTouchWhenHighlighted = YES;
30183015
albumInfoButton.frame = CGRectMake(albumDetailView.bounds.size.width - INFO_BUTTON_SIZE,
30193016
albumDetailView.bounds.size.height - INFO_BUTTON_SIZE - TINY_PADDING,
30203017
INFO_BUTTON_SIZE,
@@ -3827,9 +3824,7 @@ - (void)toggleFullscreen {
38273824
animations:^{
38283825
collectionView.alpha = 1;
38293826
dataList.alpha = 1;
3830-
UIImage *buttonImage = [UIImage imageNamed:@"button_fullscreen"];
3831-
buttonImage = [Utilities colorizeImage:buttonImage withColor:ICON_TINT_COLOR];
3832-
[fullscreenButton setImage:buttonImage forState:UIControlStateNormal];
3827+
[fullscreenButton setIconStyle:[UIImage imageNamed:@"button_fullscreen"]];
38333828
fullscreenButton.backgroundColor = UIColor.clearColor;
38343829
}
38353830
completion:^(BOOL finished) {
@@ -3893,9 +3888,7 @@ - (void)toggleFullscreen {
38933888
options:UIViewAnimationOptionCurveEaseInOut
38943889
animations:^{
38953890
collectionView.alpha = 1;
3896-
UIImage *buttonImage = [UIImage imageNamed:@"button_exit_fullscreen"];
3897-
buttonImage = [Utilities colorizeImage:buttonImage withColor:ICON_TINT_COLOR];
3898-
[fullscreenButton setImage:buttonImage forState:UIControlStateNormal];
3891+
[fullscreenButton setIconStyle:[UIImage imageNamed:@"button_exit_fullscreen"]];
38993892
fullscreenButton.backgroundColor = INFO_POPOVER_COLOR;
39003893
}
39013894
completion:^(BOOL finished) {
@@ -5440,22 +5433,14 @@ - (void)buildButtons:(int)activeTab {
54405433
mainMenu *menuItem = self.detailItem;
54415434
NSArray *buttons = menuItem.mainButtons;
54425435
NSArray *buttonsIB = @[button1, button2, button3, button4, button5];
5443-
UIImage *imageOff = nil;
5444-
UIImage *imageOn = nil;
5445-
UIImage *img = nil;
54465436
CGRect frame;
54475437
NSInteger count = buttons.count;
54485438
// If >6 buttons are required, only use 4 normal buttons and keep 5th for "more items"
54495439
if (count > MAX_NORMAL_BUTTONS + 1) {
54505440
count = MAX_NORMAL_BUTTONS;
54515441
}
54525442
for (int i = 0; i < count; i++) {
5453-
img = [UIImage imageNamed:buttons[i]];
5454-
imageOff = [Utilities colorizeImage:img withColor:ICON_TINT_COLOR];
5455-
imageOn = [Utilities colorizeImage:img withColor:ICON_TINT_COLOR_ACTIVE];
5456-
[buttonsIB[i] setBackgroundImage:imageOff forState:UIControlStateNormal];
5457-
[buttonsIB[i] setBackgroundImage:imageOn forState:UIControlStateSelected];
5458-
[buttonsIB[i] setBackgroundImage:imageOn forState:UIControlStateHighlighted];
5443+
[buttonsIB[i] setDatabaseToolbarStyle:[UIImage imageNamed:buttons[i]]];
54595444
[buttonsIB[i] setEnabled:YES];
54605445
}
54615446
activeTab = MIN(activeTab, MAX_NORMAL_BUTTONS);
@@ -5485,12 +5470,7 @@ - (void)buildButtons:(int)activeTab {
54855470
break;
54865471
default:
54875472
// 6 or more buttons/actions require a "more" button
5488-
img = [UIImage imageNamed:@"st_more"];
5489-
imageOff = [Utilities colorizeImage:img withColor:ICON_TINT_COLOR];
5490-
imageOn = [Utilities colorizeImage:img withColor:ICON_TINT_COLOR_ACTIVE];
5491-
[buttonsIB.lastObject setBackgroundImage:imageOff forState:UIControlStateNormal];
5492-
[buttonsIB.lastObject setBackgroundImage:imageOn forState:UIControlStateSelected];
5493-
[buttonsIB.lastObject setBackgroundImage:imageOn forState:UIControlStateHighlighted];
5473+
[buttonsIB.lastObject setDatabaseToolbarStyle:[UIImage imageNamed:@"st_more"]];
54945474
[buttonsIB.lastObject setEnabled:YES];
54955475
break;
54965476
}
@@ -6071,12 +6051,9 @@ - (void)checkFullscreenButton:(BOOL)forceHide {
60716051
if (fullscreenButton == nil) {
60726052
fullscreenButton = [UIButton buttonWithType:UIButtonTypeCustom];
60736053
fullscreenButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
6074-
fullscreenButton.showsTouchWhenHighlighted = YES;
60756054
fullscreenButton.frame = CGRectMake(0, 0, FULLSCREEN_BUTTON_SIZE, FULLSCREEN_BUTTON_SIZE);
60766055
fullscreenButton.contentMode = UIViewContentModeCenter;
6077-
UIImage *buttonImage = [UIImage imageNamed:@"button_fullscreen"];
6078-
buttonImage = [Utilities colorizeImage:buttonImage withColor:ICON_TINT_COLOR];
6079-
[fullscreenButton setImage:buttonImage forState:UIControlStateNormal];
6056+
[fullscreenButton setIconStyle:[UIImage imageNamed:@"button_fullscreen"]];
60806057
fullscreenButton.layer.cornerRadius = 2;
60816058
[fullscreenButton addTarget:self action:@selector(toggleFullscreen) forControlEvents:UIControlEventTouchUpInside];
60826059
fullscreenButton.frame = CGRectMake(titleView.frame.size.width - fullscreenButton.frame.size.width, titleView.frame.size.height / 2 - fullscreenButton.frame.size.height / 2, fullscreenButton.frame.size.width, fullscreenButton.frame.size.height);

XBMC Remote/DetailViewController.xib

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
<items>
8585
<barButtonItem style="plain" systemItem="flexibleSpace" id="OQd-aJ-obl"/>
8686
<barButtonItem style="plain" id="yuj-lW-yot">
87-
<button key="customView" hidden="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="117" userLabel="Button1">
87+
<button key="customView" hidden="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="117" userLabel="Button1">
8888
<rect key="frame" x="10.5" y="7" width="34" height="30"/>
8989
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
9090
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
@@ -102,7 +102,7 @@
102102
</barButtonItem>
103103
<barButtonItem style="plain" systemItem="flexibleSpace" id="IVe-28-sl6"/>
104104
<barButtonItem style="plain" id="cRW-wf-x2D">
105-
<button key="customView" hidden="YES" tag="1" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="119" userLabel="Button2">
105+
<button key="customView" hidden="YES" tag="1" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="119" userLabel="Button2">
106106
<rect key="frame" x="54.5" y="7" width="34" height="30"/>
107107
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
108108
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
@@ -120,7 +120,7 @@
120120
</barButtonItem>
121121
<barButtonItem style="plain" systemItem="flexibleSpace" id="dSm-ED-j5s"/>
122122
<barButtonItem style="plain" id="4He-Lr-2WZ">
123-
<button key="customView" hidden="YES" tag="2" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="121" userLabel="Button3">
123+
<button key="customView" hidden="YES" tag="2" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="121" userLabel="Button3">
124124
<rect key="frame" x="99" y="7" width="34" height="30"/>
125125
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
126126
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
@@ -138,7 +138,7 @@
138138
</barButtonItem>
139139
<barButtonItem style="plain" systemItem="flexibleSpace" id="Gi1-6Y-y4k"/>
140140
<barButtonItem style="plain" id="TE7-pJ-4WE">
141-
<button key="customView" hidden="YES" tag="3" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="122" userLabel="Button4">
141+
<button key="customView" hidden="YES" tag="3" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="122" userLabel="Button4">
142142
<rect key="frame" x="143" y="7" width="34" height="30"/>
143143
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
144144
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
@@ -156,7 +156,7 @@
156156
</barButtonItem>
157157
<barButtonItem style="plain" systemItem="flexibleSpace" id="ZdQ-hl-bWG"/>
158158
<barButtonItem style="plain" id="d4P-SH-Im4">
159-
<button key="customView" hidden="YES" tag="4" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="123" userLabel="Button5">
159+
<button key="customView" hidden="YES" tag="4" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="123" userLabel="Button5">
160160
<rect key="frame" x="187.5" y="7" width="34" height="30"/>
161161
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
162162
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
@@ -174,15 +174,15 @@
174174
</barButtonItem>
175175
<barButtonItem style="plain" systemItem="flexibleSpace" id="C79-Cc-JFa"/>
176176
<barButtonItem style="plain" id="rHQ-LZ-GMb">
177-
<button key="customView" hidden="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="kky-5P-ej6" userLabel="Button6">
177+
<button key="customView" hidden="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="kky-5P-ej6" userLabel="Button6">
178178
<rect key="frame" x="231.5" y="5" width="34" height="34"/>
179179
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
180180
<state key="normal" backgroundImage="st_view_list"/>
181181
</button>
182182
</barButtonItem>
183183
<barButtonItem style="plain" systemItem="flexibleSpace" id="bQB-y4-wNs"/>
184184
<barButtonItem style="plain" id="WWo-3h-QTx">
185-
<button key="customView" hidden="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="17m-9l-ySa" userLabel="Button7">
185+
<button key="customView" hidden="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="17m-9l-ySa" userLabel="Button7">
186186
<rect key="frame" x="276" y="5" width="34" height="34"/>
187187
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
188188
<state key="normal" backgroundImage="st_sort_asc"/>

XBMC Remote/HostManagementViewController.m

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -546,19 +546,15 @@ - (void)viewDidLoad {
546546
supportedVersionLabel.text = LOCALIZED_STR(@"Supported XBMC version is Eden (11) or higher");
547547

548548
editTableButton.titleLabel.font = [UIFont systemFontOfSize:15];
549-
[editTableButton setTitleColor:UIColor.grayColor forState:UIControlStateDisabled];
550-
[editTableButton setTitleColor:UIColor.grayColor forState:UIControlStateHighlighted];
551-
[editTableButton setTitleColor:UIColor.whiteColor forState:UIControlStateSelected];
549+
[editTableButton setTextStyle];
552550
editTableButton.titleLabel.shadowOffset = CGSizeZero;
553551

554552
addHostButton.titleLabel.font = [UIFont systemFontOfSize:15];
555-
[addHostButton setTitleColor:UIColor.grayColor forState:UIControlStateHighlighted];
556-
[addHostButton setTitleColor:UIColor.whiteColor forState:UIControlStateSelected];
553+
[addHostButton setTextStyle];
557554
addHostButton.titleLabel.shadowOffset = CGSizeZero;
558555

559556
serverInfoButton.titleLabel.font = [UIFont systemFontOfSize:15];
560-
[serverInfoButton setTitleColor:UIColor.grayColor forState:UIControlStateHighlighted];
561-
[serverInfoButton setTitleColor:UIColor.whiteColor forState:UIControlStateSelected];
557+
[serverInfoButton setTextStyle];
562558
serverInfoButton.titleLabel.shadowOffset = CGSizeZero;
563559

564560
serverListTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
@@ -581,8 +577,6 @@ - (void)viewDidLoad {
581577
UIImage *image = [UIImage imageNamed:@"kodi_logo_wide"];
582578
UIButton *xbmcLogo = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)];
583579
[xbmcLogo setImage:image forState:UIControlStateNormal];
584-
[xbmcLogo setImage:image forState:UIControlStateHighlighted];
585-
xbmcLogo.showsTouchWhenHighlighted = NO;
586580
[xbmcLogo addTarget:self action:@selector(infoView) forControlEvents:UIControlEventTouchUpInside];
587581
self.navigationItem.titleView = xbmcLogo;
588582
UIImage *menuImg = [UIImage imageNamed:@"button_menu"];

0 commit comments

Comments
 (0)