Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Ivan Sein 2021-03-30 21:10:37 +02:00
Родитель b52e91444a
Коммит 9942cd3d12
5 изменённых файлов: 189 добавлений и 36 удалений

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

@ -73,6 +73,12 @@
2C3195C224C5E2100066F221 /* ShareTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3195C024C5E2100066F221 /* ShareTableViewCell.m */; };
2C3195C324C5E2100066F221 /* ShareTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2C3195C124C5E2100066F221 /* ShareTableViewCell.xib */; };
2C330372255E6EBC00BDB4E4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2C330374255E6EBC00BDB4E4 /* InfoPlist.strings */; };
2C36A038261342220026F04A /* AvatarHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C36A037261342220026F04A /* AvatarHeaderView.m */; };
2C36A039261342220026F04A /* AvatarHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C36A037261342220026F04A /* AvatarHeaderView.m */; };
2C36A03A261342220026F04A /* AvatarHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C36A037261342220026F04A /* AvatarHeaderView.m */; };
2C36A03F261342FF0026F04A /* AvatarHeaderView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2C36A03E261342FF0026F04A /* AvatarHeaderView.xib */; };
2C36A040261342FF0026F04A /* AvatarHeaderView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2C36A03E261342FF0026F04A /* AvatarHeaderView.xib */; };
2C36A041261342FF0026F04A /* AvatarHeaderView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2C36A03E261342FF0026F04A /* AvatarHeaderView.xib */; };
2C3780BD2107209C003F9AE8 /* NCRoomParticipants.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3780BC2107209C003F9AE8 /* NCRoomParticipants.m */; };
2C3780C3210F49DC003F9AE8 /* HeaderWithButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C3780C2210F49DC003F9AE8 /* HeaderWithButton.m */; };
2C3780C5210F4A26003F9AE8 /* HeaderWithButton.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2C3780C4210F4A26003F9AE8 /* HeaderWithButton.xib */; };
@ -482,6 +488,9 @@
2C3195C024C5E2100066F221 /* ShareTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ShareTableViewCell.m; sourceTree = "<group>"; };
2C3195C124C5E2100066F221 /* ShareTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ShareTableViewCell.xib; sourceTree = "<group>"; };
2C330373255E6EBC00BDB4E4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
2C36A036261342220026F04A /* AvatarHeaderView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AvatarHeaderView.h; sourceTree = "<group>"; };
2C36A037261342220026F04A /* AvatarHeaderView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AvatarHeaderView.m; sourceTree = "<group>"; };
2C36A03E261342FF0026F04A /* AvatarHeaderView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AvatarHeaderView.xib; sourceTree = "<group>"; };
2C3780BB2107209C003F9AE8 /* NCRoomParticipant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NCRoomParticipant.h; sourceTree = "<group>"; };
2C3780BC2107209C003F9AE8 /* NCRoomParticipants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NCRoomParticipants.m; sourceTree = "<group>"; };
2C3780C1210F49DC003F9AE8 /* HeaderWithButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HeaderWithButton.h; sourceTree = "<group>"; };
@ -934,6 +943,9 @@
2C1EF36A25505DCE007C9768 /* NCNavigationController.m */,
1F3D3B21255F109E00230DAE /* BarButtonItemWithActivity.h */,
1F3D3B20255F109E00230DAE /* BarButtonItemWithActivity.m */,
2C36A036261342220026F04A /* AvatarHeaderView.h */,
2C36A037261342220026F04A /* AvatarHeaderView.m */,
2C36A03E261342FF0026F04A /* AvatarHeaderView.xib */,
);
name = "User Interface";
sourceTree = "<group>";
@ -1604,6 +1616,7 @@
2C7F47AA20289B9600081CC7 /* Localizable.strings in Resources */,
2C0574A51EDDA2E300D9E7F2 /* LoginViewController.xib in Resources */,
2C738158210613A200CDB8DB /* NCChatTitleView.xib in Resources */,
2C36A03F261342FF0026F04A /* AvatarHeaderView.xib in Resources */,
2C8A2BCF221FEEFE00DE6D2C /* DirectoryTableViewCell.xib in Resources */,
2CC007C620D90AE50096D91F /* RoomNameTableViewCell.xib in Resources */,
2C78EFA61F86FF4A008AFA74 /* CallParticipantViewCell.xib in Resources */,
@ -1637,6 +1650,7 @@
1F59446625B8EDF5002AD65F /* Localizable.strings in Resources */,
2C3195BD24C5A3D90066F221 /* ContactsTableViewCell.xib in Resources */,
2C62AFB624C1A449007E460A /* Share.storyboard in Resources */,
2C36A041261342FF0026F04A /* AvatarHeaderView.xib in Resources */,
2CF9CC0126025F65002246EF /* TextInputTableViewCell.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -1647,6 +1661,7 @@
files = (
1F59446225B8EDF5002AD65F /* Localizable.strings in Resources */,
2CF9CC0026025F65002246EF /* TextInputTableViewCell.xib in Resources */,
2C36A040261342FF0026F04A /* AvatarHeaderView.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1861,6 +1876,7 @@
2CBF82AE1FC888FC00636459 /* NCPushNotification.m in Sources */,
2CC7159420C54D080045C789 /* ChatTableViewCell.m in Sources */,
2CA1CCAA1F02D1A4002FE6A2 /* NCAPIController.m in Sources */,
2C36A038261342220026F04A /* AvatarHeaderView.m in Sources */,
2C3780C3210F49DC003F9AE8 /* HeaderWithButton.m in Sources */,
2C1ABDC6257A7CF000AEDFB6 /* NCContactsManager.m in Sources */,
2C5E957D227097E0009CA9BE /* NCUtils.m in Sources */,
@ -2009,6 +2025,7 @@
2C62AFFC24C1BDA5007E460A /* NCChatViewController.m in Sources */,
2C62B00E24C1BDC1007E460A /* NCNotificationController.m in Sources */,
2C78E9E52512136100E3D4CA /* NCUserStatus.m in Sources */,
2C36A03A261342220026F04A /* AvatarHeaderView.m in Sources */,
2C62B00D24C1BDC1007E460A /* NCPushNotification.m in Sources */,
1F5CDF662584E78900B0026E /* NCChatFileStatus.m in Sources */,
2C62B01C24C1BDC9007E460A /* CCCertificate.m in Sources */,
@ -2088,6 +2105,7 @@
2CC001C324A37AC500A20167 /* NCNotificationController.m in Sources */,
2CC0017524A3797600A20167 /* NCExternalSignalingController.m in Sources */,
2CC0018124A37A5800A20167 /* UIScrollView+SLKAdditions.m in Sources */,
2C36A039261342220026F04A /* AvatarHeaderView.m in Sources */,
2CC0018224A37A5B00A20167 /* UIView+SLKAdditions.m in Sources */,
2CC001B324A37A9500A20167 /* QuotedMessageView.m in Sources */,
2CC001CD24A37ACA00A20167 /* RoundedNumberView.m in Sources */,

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

@ -0,0 +1,37 @@
//
/**
* @copyright Copyright (c) 2020 Ivan Sein <ivan@nextcloud.com>
*
* @author Ivan Sein <ivan@nextcloud.com>
*
* @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>
NS_ASSUME_NONNULL_BEGIN
@interface AvatarHeaderView : UIView
@property (weak, nonatomic) IBOutlet UIImageView *avatarImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UIButton *editButton;
@property (weak, nonatomic) IBOutlet UIButton *scopeButton;
@end
NS_ASSUME_NONNULL_END

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

@ -0,0 +1,54 @@
//
/**
* @copyright Copyright (c) 2020 Ivan Sein <ivan@nextcloud.com>
*
* @author Ivan Sein <ivan@nextcloud.com>
*
* @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 "AvatarHeaderView.h"
@interface AvatarHeaderView ()
@property (strong, nonatomic) IBOutlet UIView *contentView;
@end
@implementation AvatarHeaderView
- (instancetype)init
{
self = [super init];
if (self) {
[[NSBundle mainBundle] loadNibNamed:@"AvatarHeaderView" owner:self options:nil];
[self addSubview:self.contentView];
self.editButton.titleLabel.textAlignment = NSTextAlignmentCenter;
self.editButton.titleLabel.minimumScaleFactor = 0.9f;
self.editButton.titleLabel.numberOfLines = 1;
self.editButton.titleLabel.adjustsFontSizeToFitWidth = YES;
self.contentView.frame = self.bounds;
}
return self;
}
@end

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

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="AvatarHeaderView">
<connections>
<outlet property="avatarImageView" destination="P5c-gH-ijQ" id="jla-8k-Ttl"/>
<outlet property="contentView" destination="iN0-l3-epB" id="9z6-a7-d0W"/>
<outlet property="editButton" destination="c4X-rZ-dTo" id="w4J-F8-fEs"/>
<outlet property="nameLabel" destination="cHc-KT-D8F" id="9TU-eh-vjt"/>
<outlet property="scopeButton" destination="qSd-WE-0Jc" id="9gD-KD-zgi"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="200" height="150"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.59999999999999998" translatesAutoresizingMaskIntoConstraints="NO" id="cHc-KT-D8F">
<rect key="frame" x="16" y="110" width="168" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="26"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="c4X-rZ-dTo">
<rect key="frame" x="20" y="105" width="160" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="Edit"/>
</button>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="toF-wm-Jvh">
<rect key="frame" x="20" y="0.0" width="160" height="128"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="P5c-gH-ijQ">
<rect key="frame" x="40" y="20" width="80" height="80"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qSd-WE-0Jc">
<rect key="frame" x="120" y="20" width="40" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<inset key="contentEdgeInsets" minX="10" minY="2" maxX="10" maxY="18"/>
</button>
</subviews>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="124.6376811594203" y="-184.15178571428569"/>
</view>
</objects>
</document>

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

@ -25,6 +25,7 @@
#import <AVFoundation/AVFoundation.h>
#import <TOCropViewController/TOCropViewController.h>
#import "AvatarHeaderView.h"
#import "HeaderWithButton.h"
#import "NBPhoneNumberUtil.h"
#import "NCAppBranding.h"
@ -41,6 +42,7 @@
#define k_address_textfield_tag 96
#define k_website_textfield_tag 95
#define k_twitter_textfield_tag 94
#define k_avatar_scope_button_tag 93
typedef enum ProfileSection {
kProfileSectionName = 0,
@ -256,46 +258,27 @@ typedef enum SummaryRow {
- (UIView *)avatarHeaderView
{
BOOL shouldShowEditAvatarButton = _isEditable && [[NCSettingsController sharedInstance] serverHasTalkCapability:kCapabilityTempUserAvatarAPI forAccountId:_account.accountId];
AvatarHeaderView *headerView = [[AvatarHeaderView alloc] init];
headerView.frame = CGRectMake(0, 0, 200, 150);
CGFloat headerViewHeight = (shouldShowEditAvatarButton) ? 140 : 160;
UIView *avatarView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 80, headerViewHeight)];
[avatarView setAutoresizingMask:UIViewAutoresizingNone];
avatarView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
headerView.avatarImageView.layer.cornerRadius = 40.0;
headerView.avatarImageView.layer.masksToBounds = YES;
[headerView.avatarImageView setImage:[[NCAPIController sharedInstance] userProfileImageForAccount:_account withSize:CGSizeMake(160, 160)]];
UIImageView *avatarImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 20, 80, 80)];
avatarImageView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
avatarImageView.layer.cornerRadius = 40.0;
avatarImageView.layer.masksToBounds = YES;
[avatarImageView setImage:[[NCAPIController sharedInstance] userProfileImageForAccount:_account withSize:CGSizeMake(160, 160)]];
[avatarView addSubview:avatarImageView];
headerView.nameLabel.text = _account.userDisplayName;
headerView.nameLabel.hidden = _isEditable;
if (!_isEditable) {
UILabel *displayNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 110, 80, 30)];
displayNameLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
displayNameLabel.font = [UIFont systemFontOfSize:26];
displayNameLabel.textAlignment = NSTextAlignmentCenter;
displayNameLabel.minimumScaleFactor = 0.6f;
displayNameLabel.numberOfLines = 1;
displayNameLabel.adjustsFontSizeToFitWidth = YES;
displayNameLabel.text = _account.userDisplayName;
[avatarView addSubview:displayNameLabel];
}
headerView.scopeButton.tag = k_avatar_scope_button_tag;
[headerView.scopeButton setImage:[self imageForScope:_account.avatarScope] forState:UIControlStateNormal];
[headerView.scopeButton addTarget:self action:@selector(showScopeSelectionDialog:) forControlEvents:UIControlEventTouchUpInside];
headerView.scopeButton.hidden = !(_isEditable && _showScopes);
_editAvatarButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 110, 160, 24)];
[_editAvatarButton setTitle:NSLocalizedString(@"Edit", nil) forState:UIControlStateNormal];
[_editAvatarButton setTitleColor:[UIColor systemBlueColor] forState:UIControlStateNormal];
_editAvatarButton.titleLabel.font = [UIFont systemFontOfSize:15];
_editAvatarButton.titleLabel.textAlignment = NSTextAlignmentCenter;
_editAvatarButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
_editAvatarButton.titleLabel.minimumScaleFactor = 0.9f;
_editAvatarButton.titleLabel.numberOfLines = 1;
_editAvatarButton.titleLabel.adjustsFontSizeToFitWidth = YES;
_editAvatarButton.hidden = !shouldShowEditAvatarButton;
[_editAvatarButton addTarget:self action:@selector(showAvatarOptions) forControlEvents:UIControlEventTouchUpInside];
[avatarView addSubview:_editAvatarButton];
headerView.editButton.hidden = !(_isEditable && [[NCSettingsController sharedInstance] serverHasTalkCapability:kCapabilityTempUserAvatarAPI forAccountId:_account.accountId]);
[headerView.editButton setTitle:NSLocalizedString(@"Edit", nil) forState:UIControlStateNormal];
[headerView.editButton addTarget:self action:@selector(showAvatarOptions) forControlEvents:UIControlEventTouchUpInside];
_editAvatarButton = headerView.editButton;
return avatarView;
return headerView;
}
- (void)showAvatarOptions
@ -507,6 +490,8 @@ typedef enum SummaryRow {
field = kUserProfileWebsiteScope;
} else if (sender.tag == k_twitter_textfield_tag) {
field = kUserProfileTwitterScope;
} else if (sender.tag == k_avatar_scope_button_tag) {
field = kUserProfileAvatarScope;
}
UIAlertController *scopesActionSheet =
@ -869,7 +854,7 @@ typedef enum SummaryRow {
case kProfileSectionAddAccount:
return 40;
case kProfileSectionSummary:
return 10;
return 20;
default:
return 0;
}