Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
coderZsq committed Sep 25, 2019
1 parent 665fe6d commit 4010d57
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 26 deletions.
2 changes: 2 additions & 0 deletions SQManagement/SQManagement/Coms/SQProfileHeaderView.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN

@interface SQProfileHeaderView : UIView

@property (weak, nonatomic) IBOutlet UIImageView *profileImageView;

+ (instancetype)headerView;

@end
Expand Down
6 changes: 6 additions & 0 deletions SQManagement/SQManagement/Coms/SQProfileHeaderView.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ @implementation SQProfileHeaderView

+ (instancetype)headerView {
SQProfileHeaderView *headerView = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self.class) owner:nil options:nil].firstObject;
headerView.profileImageView.layer.cornerRadius = 10;
headerView.profileImageView.layer.masksToBounds = YES;
headerView.profileImageView.layer.shadowColor = [UIColor lightGrayColor].CGColor;
headerView.profileImageView.layer.shadowOffset = CGSizeMake(5, 5);
headerView.profileImageView.layer.shadowOpacity = 0.8;
headerView.profileImageView.layer.shadowRadius = 4;
return headerView;
}

Expand Down
9 changes: 6 additions & 3 deletions SQManagement/SQManagement/Coms/SQProfileHeaderView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="SQProfileHeaderView">
<rect key="frame" x="0.0" y="0.0" width="400" height="100"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="o1g-8a-GJh">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="o1g-8a-GJh">
<rect key="frame" x="160" y="10" width="80" height="80"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="0.29999999999999999" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="backgroundColor" red="0.97254901960784312" green="0.97254901960784312" blue="0.97254901960784312" alpha="0.29999999999999999" colorSpace="custom" customColorSpace="displayP3"/>
<constraints>
<constraint firstAttribute="height" constant="80" id="6oK-aD-8Wl"/>
<constraint firstAttribute="width" constant="80" id="IUs-Wf-eZO"/>
Expand All @@ -30,6 +30,9 @@
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<connections>
<outlet property="profileImageView" destination="o1g-8a-GJh" id="lZR-Md-VHv"/>
</connections>
<point key="canvasLocation" x="-1.4492753623188408" y="-16.071428571428569"/>
</view>
</objects>
Expand Down
6 changes: 5 additions & 1 deletion SQManagement/SQManagement/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<plist version="1.0">
<dict>
<key>NSContactsUsageDescription</key>
<string>12345678</string>
<string></string>
<key>NSPhotoLibraryUsageDescription</key>
<string></string>
<key>NSCameraUsageDescription</key>
<string></string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand Down
70 changes: 48 additions & 22 deletions SQManagement/SQManagement/UI/SQAddConnectionViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,56 @@
#import "SQProfileHeaderView.h"
#import "SQConnectionPropertyCell.h"
#import "UIColor+SQExtension.h"
#import "UIView+SQExtension.h"

@interface SQAddConnectionViewController ()
@interface SQAddConnectionViewController () <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
@property (nonatomic, strong) NSArray *dataSource;
@property (nonatomic, strong) SQProfileHeaderView *headerView;
@end

@implementation SQAddConnectionViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"新增人脉";
self.tableView.backgroundColor = [UIColor colorWithHexString:@"f8f8f8"];
self.dataSource = @[
@[@"姓名",
@"角色",
@"职业",
@"地区",
@"行业",
@"影响力",
@"亲密程度",
@"黄金人脉圈"],
@[@"联系方式",
@"社交记录"],
@[@"特征",
@"工作",
@"爱好",
@"特殊细节",
@"给我的启发"],
];
[self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([SQConnectionPropertyCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([SQConnectionPropertyCell class])];
{
self.title = @"新增人脉";
self.dataSource = @[
@[@"姓名", @"角色", @"职业", @"地区", @"行业", @"影响力", @"亲密程度", @"黄金人脉圈"],
@[@"联系方式", @"社交记录"],
@[@"特征", @"工作", @"爱好", @"特殊细节", @"给我的启发"],
];
}

{
self.tableView.backgroundColor = [UIColor colorWithHexString:@"f8f8f8"];
[self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([SQConnectionPropertyCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([SQConnectionPropertyCell class])];
}

{
self.headerView = [SQProfileHeaderView headerView];
__weak typeof(self) weakSelf = self;
[self.headerView whenTapped:^{
UIImagePickerController *imagePickerVc = [[UIImagePickerController alloc] init];
imagePickerVc.delegate = self;
imagePickerVc.allowsEditing = YES;
UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:(UIAlertControllerStyleActionSheet)];
[alertVc addAction:[UIAlertAction actionWithTitle:@"立即拍摄照片" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
imagePickerVc.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerVc.cameraDevice = UIImagePickerControllerCameraDeviceRear;
[self presentViewController:imagePickerVc animated:YES completion:nil];
}
}]];
[alertVc addAction:[UIAlertAction actionWithTitle:@"从相册中获取" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]){
imagePickerVc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:imagePickerVc animated:YES completion:nil];
}
}]];
[alertVc addAction:[UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:nil]];
[weakSelf presentViewController:alertVc animated:YES completion:nil];
}];
}
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
Expand Down Expand Up @@ -66,7 +87,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
if (section == 0) return [SQProfileHeaderView headerView];
if (section == 0) return self.headerView;
return nil;
}

Expand All @@ -75,6 +96,11 @@ - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSIntege
return 1;
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion:nil];
self.headerView.profileImageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];
}

- (IBAction)doneButtonClick:(UIBarButtonItem *)sender {
[self dismiss];
}
Expand Down

0 comments on commit 4010d57

Please sign in to comment.