Skip to content

Commit 6fbbb61

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 af98892 commit 6fbbb61

12 files changed

+113
-153
lines changed

XBMC Remote/DetailViewController.m

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

824824
- (void)setGridListButtonImage:(BOOL)isGridView {
825825
NSString *imgName = isGridView ? @"st_view_grid" : @"st_view_list";
826-
UIImage *image = [Utilities colorizeImage:[UIImage imageNamed:imgName] withColor:ICON_TINT_COLOR];
827-
[button6 setBackgroundImage:image forState:UIControlStateNormal];
826+
[button6 setDatabaseToolbarStyle:[UIImage imageNamed:imgName]];
828827
}
829828

830829
- (void)setSortButtonImage:(NSString*)sortOrder {
831830
NSString *imgName = [sortOrder isEqualToString:@"descending"] ? @"st_sort_desc" : @"st_sort_asc";
832-
UIImage *image = [Utilities colorizeImage:[UIImage imageNamed:imgName] withColor:ICON_TINT_COLOR];
833-
[button7 setBackgroundImage:image forState:UIControlStateNormal];
831+
[button7 setDatabaseToolbarStyle:[UIImage imageNamed:imgName]];
834832
}
835833

836834
- (void)setButtonViewContent:(int)activeTab {
@@ -3018,7 +3016,6 @@ - (void)layoutSectionView:(UIView*)albumDetailView thumbView:(UIImageView*)thumb
30183016

30193017
// Add Info button to bottom-right corner
30203018
albumInfoButton.alpha = 0.8;
3021-
albumInfoButton.showsTouchWhenHighlighted = YES;
30223019
albumInfoButton.frame = CGRectMake(albumDetailView.bounds.size.width - INFO_BUTTON_SIZE,
30233020
albumDetailView.bounds.size.height - INFO_BUTTON_SIZE - TINY_PADDING,
30243021
INFO_BUTTON_SIZE,
@@ -3829,9 +3826,7 @@ - (void)toggleFullscreen {
38293826
animations:^{
38303827
collectionView.alpha = 1;
38313828
dataList.alpha = 1;
3832-
UIImage *buttonImage = [UIImage imageNamed:@"button_fullscreen"];
3833-
buttonImage = [Utilities colorizeImage:buttonImage withColor:ICON_TINT_COLOR];
3834-
[fullscreenButton setImage:buttonImage forState:UIControlStateNormal];
3829+
[fullscreenButton setIconStyle:[UIImage imageNamed:@"button_fullscreen"]];
38353830
fullscreenButton.backgroundColor = UIColor.clearColor;
38363831
}
38373832
completion:^(BOOL finished) {
@@ -3895,9 +3890,7 @@ - (void)toggleFullscreen {
38953890
options:UIViewAnimationOptionCurveEaseInOut
38963891
animations:^{
38973892
collectionView.alpha = 1;
3898-
UIImage *buttonImage = [UIImage imageNamed:@"button_exit_fullscreen"];
3899-
buttonImage = [Utilities colorizeImage:buttonImage withColor:ICON_TINT_COLOR];
3900-
[fullscreenButton setImage:buttonImage forState:UIControlStateNormal];
3893+
[fullscreenButton setIconStyle:[UIImage imageNamed:@"button_exit_fullscreen"]];
39013894
fullscreenButton.backgroundColor = INFO_POPOVER_COLOR;
39023895
}
39033896
completion:^(BOOL finished) {
@@ -5445,22 +5438,14 @@ - (void)buildButtons:(int)activeTab {
54455438
mainMenu *menuItem = self.detailItem;
54465439
NSArray *buttons = menuItem.mainButtons;
54475440
NSArray *buttonsIB = @[button1, button2, button3, button4, button5];
5448-
UIImage *imageOff = nil;
5449-
UIImage *imageOn = nil;
5450-
UIImage *img = nil;
54515441
CGRect frame;
54525442
NSInteger count = buttons.count;
54535443
// If >6 buttons are required, only use 4 normal buttons and keep 5th for "more items"
54545444
if (count > MAX_NORMAL_BUTTONS + 1) {
54555445
count = MAX_NORMAL_BUTTONS;
54565446
}
54575447
for (int i = 0; i < count; i++) {
5458-
img = [UIImage imageNamed:buttons[i]];
5459-
imageOff = [Utilities colorizeImage:img withColor:ICON_TINT_COLOR];
5460-
imageOn = [Utilities colorizeImage:img withColor:ICON_TINT_COLOR_ACTIVE];
5461-
[buttonsIB[i] setBackgroundImage:imageOff forState:UIControlStateNormal];
5462-
[buttonsIB[i] setBackgroundImage:imageOn forState:UIControlStateSelected];
5463-
[buttonsIB[i] setBackgroundImage:imageOn forState:UIControlStateHighlighted];
5448+
[buttonsIB[i] setDatabaseToolbarStyle:[UIImage imageNamed:buttons[i]]];
54645449
[buttonsIB[i] setEnabled:YES];
54655450
}
54665451
activeTab = MIN(activeTab, MAX_NORMAL_BUTTONS);
@@ -5500,12 +5485,7 @@ - (void)buildButtons:(int)activeTab {
55005485
break;
55015486
default:
55025487
// 6 or more buttons/actions require a "more" button
5503-
img = [UIImage imageNamed:@"st_more"];
5504-
imageOff = [Utilities colorizeImage:img withColor:ICON_TINT_COLOR];
5505-
imageOn = [Utilities colorizeImage:img withColor:ICON_TINT_COLOR_ACTIVE];
5506-
[buttonsIB.lastObject setBackgroundImage:imageOff forState:UIControlStateNormal];
5507-
[buttonsIB.lastObject setBackgroundImage:imageOn forState:UIControlStateSelected];
5508-
[buttonsIB.lastObject setBackgroundImage:imageOn forState:UIControlStateHighlighted];
5488+
[buttonsIB.lastObject setDatabaseToolbarStyle:[UIImage imageNamed:@"st_more"]];
55095489
[buttonsIB.lastObject setEnabled:YES];
55105490
break;
55115491
}
@@ -6097,12 +6077,9 @@ - (void)checkFullscreenButton:(BOOL)forceHide {
60976077
if (fullscreenButton == nil) {
60986078
fullscreenButton = [UIButton buttonWithType:UIButtonTypeCustom];
60996079
fullscreenButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
6100-
fullscreenButton.showsTouchWhenHighlighted = YES;
61016080
fullscreenButton.frame = CGRectMake(0, 0, FULLSCREEN_BUTTON_SIZE, FULLSCREEN_BUTTON_SIZE);
61026081
fullscreenButton.contentMode = UIViewContentModeCenter;
6103-
UIImage *buttonImage = [UIImage imageNamed:@"button_fullscreen"];
6104-
buttonImage = [Utilities colorizeImage:buttonImage withColor:ICON_TINT_COLOR];
6105-
[fullscreenButton setImage:buttonImage forState:UIControlStateNormal];
6082+
[fullscreenButton setIconStyle:[UIImage imageNamed:@"button_fullscreen"]];
61066083
fullscreenButton.layer.cornerRadius = 2;
61076084
[fullscreenButton addTarget:self action:@selector(toggleFullscreen) forControlEvents:UIControlEventTouchUpInside];
61086085
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
@@ -76,7 +76,7 @@
7676
<items>
7777
<barButtonItem style="plain" systemItem="flexibleSpace" id="OQd-aJ-obl"/>
7878
<barButtonItem style="plain" id="yuj-lW-yot">
79-
<button key="customView" hidden="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="117" userLabel="Button1">
79+
<button key="customView" hidden="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="117" userLabel="Button1">
8080
<rect key="frame" x="10.5" y="7" width="34" height="30"/>
8181
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
8282
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
@@ -94,7 +94,7 @@
9494
</barButtonItem>
9595
<barButtonItem style="plain" systemItem="flexibleSpace" id="IVe-28-sl6"/>
9696
<barButtonItem style="plain" id="cRW-wf-x2D">
97-
<button key="customView" hidden="YES" tag="1" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="119" userLabel="Button2">
97+
<button key="customView" hidden="YES" tag="1" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="119" userLabel="Button2">
9898
<rect key="frame" x="54.5" y="7" width="34" height="30"/>
9999
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
100100
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
@@ -112,7 +112,7 @@
112112
</barButtonItem>
113113
<barButtonItem style="plain" systemItem="flexibleSpace" id="dSm-ED-j5s"/>
114114
<barButtonItem style="plain" id="4He-Lr-2WZ">
115-
<button key="customView" hidden="YES" tag="2" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="121" userLabel="Button3">
115+
<button key="customView" hidden="YES" tag="2" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="121" userLabel="Button3">
116116
<rect key="frame" x="99" y="7" width="34" height="30"/>
117117
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
118118
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
@@ -130,7 +130,7 @@
130130
</barButtonItem>
131131
<barButtonItem style="plain" systemItem="flexibleSpace" id="Gi1-6Y-y4k"/>
132132
<barButtonItem style="plain" id="TE7-pJ-4WE">
133-
<button key="customView" hidden="YES" tag="3" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="122" userLabel="Button4">
133+
<button key="customView" hidden="YES" tag="3" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="122" userLabel="Button4">
134134
<rect key="frame" x="143" y="7" width="34" height="30"/>
135135
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
136136
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
@@ -148,7 +148,7 @@
148148
</barButtonItem>
149149
<barButtonItem style="plain" systemItem="flexibleSpace" id="ZdQ-hl-bWG"/>
150150
<barButtonItem style="plain" id="d4P-SH-Im4">
151-
<button key="customView" hidden="YES" tag="4" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="123" userLabel="Button5">
151+
<button key="customView" hidden="YES" tag="4" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="123" userLabel="Button5">
152152
<rect key="frame" x="187.5" y="7" width="34" height="30"/>
153153
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
154154
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
@@ -166,15 +166,15 @@
166166
</barButtonItem>
167167
<barButtonItem style="plain" systemItem="flexibleSpace" id="C79-Cc-JFa"/>
168168
<barButtonItem style="plain" id="rHQ-LZ-GMb">
169-
<button key="customView" hidden="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="kky-5P-ej6" userLabel="Button6">
169+
<button key="customView" hidden="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="kky-5P-ej6" userLabel="Button6">
170170
<rect key="frame" x="231.5" y="5" width="34" height="34"/>
171171
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
172172
<state key="normal" backgroundImage="st_view_list"/>
173173
</button>
174174
</barButtonItem>
175175
<barButtonItem style="plain" systemItem="flexibleSpace" id="bQB-y4-wNs"/>
176176
<barButtonItem style="plain" id="WWo-3h-QTx">
177-
<button key="customView" hidden="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="17m-9l-ySa" userLabel="Button7">
177+
<button key="customView" hidden="YES" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="17m-9l-ySa" userLabel="Button7">
178178
<rect key="frame" x="276" y="5" width="34" height="34"/>
179179
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
180180
<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
@@ -549,19 +549,15 @@ - (void)viewDidLoad {
549549
supportedVersionLabel.text = LOCALIZED_STR(@"Supported XBMC version is Eden (11) or higher");
550550

551551
editTableButton.titleLabel.font = [UIFont systemFontOfSize:15];
552-
[editTableButton setTitleColor:UIColor.grayColor forState:UIControlStateDisabled];
553-
[editTableButton setTitleColor:UIColor.grayColor forState:UIControlStateHighlighted];
554-
[editTableButton setTitleColor:UIColor.whiteColor forState:UIControlStateSelected];
552+
[editTableButton setTextStyle];
555553
editTableButton.titleLabel.shadowOffset = CGSizeZero;
556554

557555
addHostButton.titleLabel.font = [UIFont systemFontOfSize:15];
558-
[addHostButton setTitleColor:UIColor.grayColor forState:UIControlStateHighlighted];
559-
[addHostButton setTitleColor:UIColor.whiteColor forState:UIControlStateSelected];
556+
[addHostButton setTextStyle];
560557
addHostButton.titleLabel.shadowOffset = CGSizeZero;
561558

562559
serverInfoButton.titleLabel.font = [UIFont systemFontOfSize:15];
563-
[serverInfoButton setTitleColor:UIColor.grayColor forState:UIControlStateHighlighted];
564-
[serverInfoButton setTitleColor:UIColor.whiteColor forState:UIControlStateSelected];
560+
[serverInfoButton setTextStyle];
565561
serverInfoButton.titleLabel.shadowOffset = CGSizeZero;
566562

567563
serverListTableView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
@@ -584,8 +580,6 @@ - (void)viewDidLoad {
584580
UIImage *image = [UIImage imageNamed:@"kodi_logo_wide"];
585581
UIButton *xbmcLogo = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)];
586582
[xbmcLogo setImage:image forState:UIControlStateNormal];
587-
[xbmcLogo setImage:image forState:UIControlStateHighlighted];
588-
xbmcLogo.showsTouchWhenHighlighted = NO;
589583
[xbmcLogo addTarget:self action:@selector(infoView) forControlEvents:UIControlEventTouchUpInside];
590584
self.navigationItem.titleView = xbmcLogo;
591585
UIImage *menuImg = [UIImage imageNamed:@"button_menu"];

0 commit comments

Comments
 (0)