Added BarButtonItemWithActivity

Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
This commit is contained in:
Marcel Müller 2020-11-13 20:08:08 +01:00 коммит произвёл Marcel Müller
Родитель d71b593621
Коммит 7d95f33935
3 изменённых файлов: 119 добавлений и 0 удалений

Просмотреть файл

@ -7,6 +7,9 @@
objects = {
/* Begin PBXBuildFile section */
1F3D3B22255F109E00230DAE /* BarButtonItemWithActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F3D3B20255F109E00230DAE /* BarButtonItemWithActivity.m */; };
1F3D3B23255F109E00230DAE /* BarButtonItemWithActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F3D3B20255F109E00230DAE /* BarButtonItemWithActivity.m */; };
1F3D3B24255F109E00230DAE /* BarButtonItemWithActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F3D3B20255F109E00230DAE /* BarButtonItemWithActivity.m */; };
2C0574821EDD9E8E00D9E7F2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C0574811EDD9E8E00D9E7F2 /* main.m */; };
2C0574851EDD9E8E00D9E7F2 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C0574841EDD9E8E00D9E7F2 /* AppDelegate.m */; };
2C05748E1EDD9E8E00D9E7F2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2C05748C1EDD9E8E00D9E7F2 /* Main.storyboard */; };
@ -443,6 +446,8 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
1F3D3B20255F109E00230DAE /* BarButtonItemWithActivity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BarButtonItemWithActivity.m; sourceTree = "<group>"; };
1F3D3B21255F109E00230DAE /* BarButtonItemWithActivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BarButtonItemWithActivity.h; sourceTree = "<group>"; };
2C05747D1EDD9E8E00D9E7F2 /* NextcloudTalk.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NextcloudTalk.app; sourceTree = BUILT_PRODUCTS_DIR; };
2C0574811EDD9E8E00D9E7F2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
2C0574831EDD9E8E00D9E7F2 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@ -949,6 +954,8 @@
2C9200C22474262C0050084F /* UIBarButtonItem+Badge.m */,
2C1EF36925505DCE007C9768 /* NCNavigationController.h */,
2C1EF36A25505DCE007C9768 /* NCNavigationController.m */,
1F3D3B21255F109E00230DAE /* BarButtonItemWithActivity.h */,
1F3D3B20255F109E00230DAE /* BarButtonItemWithActivity.m */,
);
name = "User Interface";
sourceTree = "<group>";
@ -1915,6 +1922,7 @@
2C961E0D2216BF4B00F5C23F /* OCActivity.m in Sources */,
2C961E1D2216BF4B00F5C23F /* OCXMLParser.m in Sources */,
2C961E1A2216BF4B00F5C23F /* OCHTTPRequestOperation.m in Sources */,
1F3D3B22255F109E00230DAE /* BarButtonItemWithActivity.m in Sources */,
2C0574821EDD9E8E00D9E7F2 /* main.m in Sources */,
2C40281522832EED0000DDFC /* NCDatabaseManager.m in Sources */,
2CC007B820D8139D0096D91F /* RoomCreationTableViewController.m in Sources */,
@ -2005,6 +2013,7 @@
2C62AFBC24C1BD69007E460A /* FTPopOverMenu.m in Sources */,
2C62AFEA24C1BD99007E460A /* NCCallController.m in Sources */,
2C62AFC724C1BD78007E460A /* NCRichDocumentTemplate.m in Sources */,
1F3D3B24255F109E00230DAE /* BarButtonItemWithActivity.m in Sources */,
2C62AFF324C1BD9F007E460A /* MessageSeparatorTableViewCell.m in Sources */,
2C62AFE724C1BD99007E460A /* CallParticipantViewCell.m in Sources */,
2C62AFE624C1BD91007E460A /* RTCSessionDescription+JSON.m in Sources */,
@ -2212,6 +2221,7 @@
2CC0016724A25BE100A20167 /* NCChatMessage.m in Sources */,
2CC0018524A37A6600A20167 /* OCCapabilities.m in Sources */,
2CC0019824A37A7400A20167 /* UtilsFramework.m in Sources */,
1F3D3B23255F109E00230DAE /* BarButtonItemWithActivity.m in Sources */,
2CC001D024A37ACA00A20167 /* RoomTableViewCell.m in Sources */,
2CC0015D24A257B800A20167 /* NCSettingsController.m in Sources */,
2CC0017424A3796400A20167 /* NCAPISessionManager.m in Sources */,

Просмотреть файл

@ -0,0 +1,35 @@
/**
* @copyright Copyright (c) 2020 Marcel Müller <marcel-mueller@gmx.de>
*
* @author Marcel Müller <marcel-mueller@gmx.de>
*
* @license GNU GPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#import <UIKit/UIKit.h>
@interface BarButtonItemWithActivity : UIBarButtonItem
@property (nonatomic, strong) UIButton *innerButton;
@property (nonatomic, strong) UIActivityIndicatorView *activityIndicator;
- (instancetype)initWithWidth:(CGFloat)buttonWidth withImage:(UIImage *)buttonImage;
- (void)showActivityIndicator;
- (void)hideActivityIndicator;
@end

Просмотреть файл

@ -0,0 +1,74 @@
/**
* @copyright Copyright (c) 2020 Marcel Müller <marcel-mueller@gmx.de>
*
* @author Marcel Müller <marcel-mueller@gmx.de>
*
* @license GNU GPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#import "BarButtonItemWithActivity.h"
#import "NCAppBranding.h"
@interface BarButtonItemWithActivity ()
@end
@implementation BarButtonItemWithActivity
- (instancetype)init {
return [super init];
}
- (instancetype)initWithWidth:(CGFloat)buttonWidth withImage:(UIImage *)buttonImage {
self = [self init];
if (self) {
UIColor *themeColor = [NCAppBranding themeTextColor];
// Use UIButton as CustomView in UIBarButtonItem to have a fixed-size item
self.innerButton = [[UIButton alloc] init];
[self.innerButton setImage:buttonImage forState:UIControlStateNormal];
self.innerButton.tintColor = UIColor.whiteColor;
self.innerButton.frame = CGRectMake(0, 0, buttonWidth, 0);
self.innerButton.tintColor = themeColor;
// Make sure the size of UIBarButtonItem stays the same when displaying the ActivityIndicator
self.activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
self.activityIndicator.tintColor = themeColor;
self.activityIndicator.frame = CGRectMake(0, 0, buttonWidth, 0);
[self setCustomView:self.innerButton];
}
return self;
}
- (void)showActivityIndicator
{
[self.activityIndicator startAnimating];
[self setCustomView:self.activityIndicator];
}
- (void)hideActivityIndicator
{
[self setCustomView:self.innerButton];
[self.activityIndicator stopAnimating];
}
@end