Skip to content

Commit 0137150

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 8e54f89 commit 0137150

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
@@ -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,
@@ -3821,9 +3818,7 @@ - (void)toggleFullscreen {
38213818
animations:^{
38223819
collectionView.alpha = 1;
38233820
dataList.alpha = 1;
3824-
UIImage *buttonImage = [UIImage imageNamed:@"button_fullscreen"];
3825-
buttonImage = [Utilities colorizeImage:buttonImage withColor:ICON_TINT_COLOR];
3826-
[fullscreenButton setImage:buttonImage forState:UIControlStateNormal];
3821+
[fullscreenButton setIconStyle:[UIImage imageNamed:@"button_fullscreen"]];
38273822
fullscreenButton.backgroundColor = UIColor.clearColor;
38283823
}
38293824
completion:^(BOOL finished) {
@@ -3887,9 +3882,7 @@ - (void)toggleFullscreen {
38873882
options:UIViewAnimationOptionCurveEaseInOut
38883883
animations:^{
38893884
collectionView.alpha = 1;
3890-
UIImage *buttonImage = [UIImage imageNamed:@"button_exit_fullscreen"];
3891-
buttonImage = [Utilities colorizeImage:buttonImage withColor:ICON_TINT_COLOR];
3892-
[fullscreenButton setImage:buttonImage forState:UIControlStateNormal];
3885+
[fullscreenButton setIconStyle:[UIImage imageNamed:@"button_exit_fullscreen"]];
38933886
fullscreenButton.backgroundColor = INFO_POPOVER_COLOR;
38943887
}
38953888
completion:^(BOOL finished) {
@@ -5434,22 +5427,14 @@ - (void)buildButtons:(int)activeTab {
54345427
mainMenu *menuItem = self.detailItem;
54355428
NSArray *buttons = menuItem.mainButtons;
54365429
NSArray *buttonsIB = @[button1, button2, button3, button4, button5];
5437-
UIImage *imageOff = nil;
5438-
UIImage *imageOn = nil;
5439-
UIImage *img = nil;
54405430
CGRect frame;
54415431
NSInteger count = buttons.count;
54425432
// If >6 buttons are required, only use 4 normal buttons and keep 5th for "more items"
54435433
if (count > MAX_NORMAL_BUTTONS + 1) {
54445434
count = MAX_NORMAL_BUTTONS;
54455435
}
54465436
for (int i = 0; i < count; i++) {
5447-
img = [UIImage imageNamed:buttons[i]];
5448-
imageOff = [Utilities colorizeImage:img withColor:ICON_TINT_COLOR];
5449-
imageOn = [Utilities colorizeImage:img withColor:ICON_TINT_COLOR_ACTIVE];
5450-
[buttonsIB[i] setBackgroundImage:imageOff forState:UIControlStateNormal];
5451-
[buttonsIB[i] setBackgroundImage:imageOn forState:UIControlStateSelected];
5452-
[buttonsIB[i] setBackgroundImage:imageOn forState:UIControlStateHighlighted];
5437+
[buttonsIB[i] setDatabaseToolbarStyle:[UIImage imageNamed:buttons[i]]];
54535438
[buttonsIB[i] setEnabled:YES];
54545439
}
54555440
activeTab = MIN(activeTab, MAX_NORMAL_BUTTONS);
@@ -5479,12 +5464,7 @@ - (void)buildButtons:(int)activeTab {
54795464
break;
54805465
default:
54815466
// 6 or more buttons/actions require a "more" button
5482-
img = [UIImage imageNamed:@"st_more"];
5483-
imageOff = [Utilities colorizeImage:img withColor:ICON_TINT_COLOR];
5484-
imageOn = [Utilities colorizeImage:img withColor:ICON_TINT_COLOR_ACTIVE];
5485-
[buttonsIB.lastObject setBackgroundImage:imageOff forState:UIControlStateNormal];
5486-
[buttonsIB.lastObject setBackgroundImage:imageOn forState:UIControlStateSelected];
5487-
[buttonsIB.lastObject setBackgroundImage:imageOn forState:UIControlStateHighlighted];
5467+
[buttonsIB.lastObject setDatabaseToolbarStyle:[UIImage imageNamed:@"st_more"]];
54885468
[buttonsIB.lastObject setEnabled:YES];
54895469
break;
54905470
}
@@ -6068,12 +6048,9 @@ - (void)checkFullscreenButton:(BOOL)forceHide {
60686048
if (fullscreenButton == nil) {
60696049
fullscreenButton = [UIButton buttonWithType:UIButtonTypeCustom];
60706050
fullscreenButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
6071-
fullscreenButton.showsTouchWhenHighlighted = YES;
60726051
fullscreenButton.frame = CGRectMake(0, 0, FULLSCREEN_BUTTON_SIZE, FULLSCREEN_BUTTON_SIZE);
60736052
fullscreenButton.contentMode = UIViewContentModeCenter;
6074-
UIImage *buttonImage = [UIImage imageNamed:@"button_fullscreen"];
6075-
buttonImage = [Utilities colorizeImage:buttonImage withColor:ICON_TINT_COLOR];
6076-
[fullscreenButton setImage:buttonImage forState:UIControlStateNormal];
6053+
[fullscreenButton setIconStyle:[UIImage imageNamed:@"button_fullscreen"]];
60776054
fullscreenButton.layer.cornerRadius = 2;
60786055
[fullscreenButton addTarget:self action:@selector(toggleFullscreen) forControlEvents:UIControlEventTouchUpInside];
60796056
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
@@ -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)