diff --git a/SQManagement/Podfile b/SQManagement/Podfile index 0de0dade..83fb0fc0 100644 --- a/SQManagement/Podfile +++ b/SQManagement/Podfile @@ -6,6 +6,5 @@ target 'SQManagement' do # use_frameworks! # Pods for SQManagement - pod 'QMUIKit' end diff --git a/SQManagement/Podfile.lock b/SQManagement/Podfile.lock index 0c968cbf..9c60cfa8 100644 --- a/SQManagement/Podfile.lock +++ b/SQManagement/Podfile.lock @@ -1,3 +1,3 @@ -PODFILE CHECKSUM: c96a98d382c67df3be677a23851945fe11a9af28 +PODFILE CHECKSUM: 3f7c4419b8b079eb1bc8490d3ee796bcbb510bb7 -COCOAPODS: 1.5.3 +COCOAPODS: 1.8.1 diff --git a/SQManagement/SQManagement.xcodeproj/project.pbxproj b/SQManagement/SQManagement.xcodeproj/project.pbxproj index c7666251..bd18cfcd 100644 --- a/SQManagement/SQManagement.xcodeproj/project.pbxproj +++ b/SQManagement/SQManagement.xcodeproj/project.pbxproj @@ -7,6 +7,9 @@ objects = { /* Begin PBXBuildFile section */ + 14040349233F887300D0BC12 /* SQTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 14040347233F887200D0BC12 /* SQTabBarController.m */; }; + 1404034A233F887300D0BC12 /* SQTabbarControllerAnimatedTransitioning.m in Sources */ = {isa = PBXBuildFile; fileRef = 14040348233F887200D0BC12 /* SQTabbarControllerAnimatedTransitioning.m */; }; + 14233205233F923700D4FA3B /* SQConnectionModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 14233204233F923700D4FA3B /* SQConnectionModel.m */; }; 142787F3233CB4AB0000FEBB /* SQTimeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 142787F2233CB4AB0000FEBB /* SQTimeViewController.m */; }; 142787F6233CBC1F0000FEBB /* SQEnergyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 142787F5233CBC1F0000FEBB /* SQEnergyViewController.m */; }; 142787FC233CBC980000FEBB /* SQH1TitleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 142787FB233CBC980000FEBB /* SQH1TitleViewController.m */; }; @@ -38,6 +41,12 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 14040345233F887200D0BC12 /* SQTabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQTabBarController.h; sourceTree = ""; }; + 14040346233F887200D0BC12 /* SQTabbarControllerAnimatedTransitioning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQTabbarControllerAnimatedTransitioning.h; sourceTree = ""; }; + 14040347233F887200D0BC12 /* SQTabBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SQTabBarController.m; sourceTree = ""; }; + 14040348233F887200D0BC12 /* SQTabbarControllerAnimatedTransitioning.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SQTabbarControllerAnimatedTransitioning.m; sourceTree = ""; }; + 14233203233F923700D4FA3B /* SQConnectionModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SQConnectionModel.h; sourceTree = ""; }; + 14233204233F923700D4FA3B /* SQConnectionModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SQConnectionModel.m; sourceTree = ""; }; 142787F1233CB4AB0000FEBB /* SQTimeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SQTimeViewController.h; sourceTree = ""; }; 142787F2233CB4AB0000FEBB /* SQTimeViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SQTimeViewController.m; sourceTree = ""; }; 142787F4233CBC1F0000FEBB /* SQEnergyViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SQEnergyViewController.h; sourceTree = ""; }; @@ -102,6 +111,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 14233206233F923C00D4FA3B /* Model */ = { + isa = PBXGroup; + children = ( + 14233203233F923700D4FA3B /* SQConnectionModel.h */, + 14233204233F923700D4FA3B /* SQConnectionModel.m */, + ); + path = Model; + sourceTree = ""; + }; 14D633B123376549004FD86A /* Tools */ = { isa = PBXGroup; children = ( @@ -139,6 +157,10 @@ 14E97DC92335014B004FC20D /* SceneDelegate.m */, 14DC37E52337509E00867A92 /* SQNavigationController.h */, 14DC37E62337509E00867A92 /* SQNavigationController.m */, + 14040345233F887200D0BC12 /* SQTabBarController.h */, + 14040347233F887200D0BC12 /* SQTabBarController.m */, + 14040346233F887200D0BC12 /* SQTabbarControllerAnimatedTransitioning.h */, + 14040348233F887200D0BC12 /* SQTabbarControllerAnimatedTransitioning.m */, 142787FA233CBC980000FEBB /* SQH1TitleViewController.h */, 142787FB233CBC980000FEBB /* SQH1TitleViewController.m */, ); @@ -201,6 +223,7 @@ 14DC37D123374F7700867A92 /* Main */, 14DC37D023374F6E00867A92 /* Coms */, 14D633B123376549004FD86A /* Tools */, + 14233206233F923C00D4FA3B /* Model */, 14DC37E423374FC300867A92 /* UI */, 14DC37D423374FA500867A92 /* SQExtension */, 14E97DCE2335014B004FC20D /* Main.storyboard */, @@ -340,11 +363,14 @@ 14E97DD32335014B004FC20D /* SQManagement.xcdatamodeld in Sources */, 14DC37CC23374CFB00867A92 /* SQH1TitleView.m in Sources */, 149AC8982339F7D4009C88AB /* SQSearchInputView.m in Sources */, + 14040349233F887300D0BC12 /* SQTabBarController.m in Sources */, 14D633B0233763FF004FD86A /* SQAuthorizationManager.m in Sources */, + 14233205233F923700D4FA3B /* SQConnectionModel.m in Sources */, 142787F6233CBC1F0000FEBB /* SQEnergyViewController.m in Sources */, 142787F3233CB4AB0000FEBB /* SQTimeViewController.m in Sources */, 149AC8882339BEE6009C88AB /* SQProfileHeaderView.m in Sources */, 14DC37E023374FA500867A92 /* NSObject+SQExtension.m in Sources */, + 1404034A233F887300D0BC12 /* SQTabbarControllerAnimatedTransitioning.m in Sources */, 14DC37CF23374DC600867A92 /* SQConnectionsViewController.m in Sources */, 149AC8852339B92F009C88AB /* SQAddConnectionViewController.m in Sources */, 14E97DCA2335014B004FC20D /* SceneDelegate.m in Sources */, diff --git a/SQManagement/SQManagement/Base.lproj/Main.storyboard b/SQManagement/SQManagement/Base.lproj/Main.storyboard index 7f321f8c..d490e597 100644 --- a/SQManagement/SQManagement/Base.lproj/Main.storyboard +++ b/SQManagement/SQManagement/Base.lproj/Main.storyboard @@ -2,7 +2,6 @@ - @@ -122,7 +121,7 @@ - + diff --git a/SQManagement/SQManagement/Coms/SQConnectionPropertyCell.h b/SQManagement/SQManagement/Coms/SQConnectionPropertyCell.h index 604e254a..1a8d3deb 100644 --- a/SQManagement/SQManagement/Coms/SQConnectionPropertyCell.h +++ b/SQManagement/SQManagement/Coms/SQConnectionPropertyCell.h @@ -13,8 +13,8 @@ NS_ASSUME_NONNULL_BEGIN @interface SQConnectionPropertyCell : UITableViewCell @property (weak, nonatomic) IBOutlet UILabel *titleLabel; +@property (weak, nonatomic) IBOutlet UILabel *inputLabel; @property (weak, nonatomic) IBOutlet UIImageView *iconImageView; -@property (weak, nonatomic) IBOutlet UITextField *contentTextField; @end diff --git a/SQManagement/SQManagement/Coms/SQConnectionPropertyCell.xib b/SQManagement/SQManagement/Coms/SQConnectionPropertyCell.xib index b20d846c..e8aa9a33 100644 --- a/SQManagement/SQManagement/Coms/SQConnectionPropertyCell.xib +++ b/SQManagement/SQManagement/Coms/SQConnectionPropertyCell.xib @@ -2,7 +2,6 @@ - @@ -17,11 +16,6 @@ - - - - - @@ -36,12 +30,17 @@ + - - - + + @@ -49,8 +48,8 @@ - + diff --git a/SQManagement/SQManagement/Main/SQH1TitleViewController.h b/SQManagement/SQManagement/Main/SQH1TitleViewController.h index 610f5870..6af12033 100644 --- a/SQManagement/SQManagement/Main/SQH1TitleViewController.h +++ b/SQManagement/SQManagement/Main/SQH1TitleViewController.h @@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN @interface SQH1TitleViewController : UITableViewController +- (BOOL)isShowNavigationShadowImage; + @end NS_ASSUME_NONNULL_END diff --git a/SQManagement/SQManagement/Main/SQH1TitleViewController.m b/SQManagement/SQManagement/Main/SQH1TitleViewController.m index eab71cba..f6cf2e00 100644 --- a/SQManagement/SQManagement/Main/SQH1TitleViewController.m +++ b/SQManagement/SQManagement/Main/SQH1TitleViewController.m @@ -9,6 +9,7 @@ #import "SQH1TitleViewController.h" #import "SQH1TitleView.h" #import "UIViewController+SQExtension.h" +#import "UIImage+SQExtension.h" @interface SQH1TitleViewController () @property (nonatomic, weak) UILabel *titleLabel; @@ -44,9 +45,20 @@ - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSIntege return 44; } +- (BOOL)isShowNavigationShadowImage { + return YES; +} + - (void)scrollViewDidScroll:(UIScrollView *)scrollView { [self.view endEditing:YES]; self.titleLabel.textColor = scrollView.contentOffset.y > -48.f ? self.defaultColor : [UIColor clearColor]; + if ([self isShowNavigationShadowImage]) { + UIColor *color = [UIColor whiteColor]; + if (self.titleLabel.textColor == self.defaultColor) { + color = [[UIColor lightGrayColor] colorWithAlphaComponent:0.3]; + } + [self.navigationController.navigationBar setShadowImage:[UIImage imageWithColor:color]]; + } } @end diff --git a/SQManagement/SQManagement/Main/SQTabBarController.h b/SQManagement/SQManagement/Main/SQTabBarController.h new file mode 100644 index 00000000..3a4ecbff --- /dev/null +++ b/SQManagement/SQManagement/Main/SQTabBarController.h @@ -0,0 +1,17 @@ +// +// SQTabBarController.h +// SQMagnet +// +// Created by 朱双泉 on 2019/7/12. +// Copyright © 2019 Castie!. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface SQTabBarController : UITabBarController + +@end + +NS_ASSUME_NONNULL_END diff --git a/SQManagement/SQManagement/Main/SQTabBarController.m b/SQManagement/SQManagement/Main/SQTabBarController.m new file mode 100644 index 00000000..0d856fb8 --- /dev/null +++ b/SQManagement/SQManagement/Main/SQTabBarController.m @@ -0,0 +1,49 @@ +// +// SQTabBarController.m +// SQMagnet +// +// Created by 朱双泉 on 2019/7/12. +// Copyright © 2019 Castie!. All rights reserved. +// + +#import "SQTabBarController.h" +#import "SQTabbarControllerAnimatedTransitioning.h" +#import "UIColor+SQExtension.h" + +@interface SQTabBarController () + +@property (nonatomic, assign) NSUInteger lastSelectIndex; + +@end + +@implementation SQTabBarController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.delegate = self; + [self hookApplicationWillEnterForeground]; +} + +- (void)hookApplicationWillEnterForeground { + self.view.backgroundColor = [UIColor whiteColor]; + if (@available(iOS 13.0, *)) { + self.view.backgroundColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull trait) { + if (trait.userInterfaceStyle == UIUserInterfaceStyleDark) { + return [UIColor colorWithHexString:@"#1c1c1e"]; + } else { + return [UIColor whiteColor]; + } + }]; + } +} + +- (id )tabBarController:(UITabBarController *)tabBarController animationControllerForTransitionFromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC { + NSUInteger fromVCIndex = [self.childViewControllers indexOfObject:fromVC]; + NSUInteger toVCIndex = [self.childViewControllers indexOfObject:toVC]; + SQTabbarControllerAnimatedTransitioning *animatedTransitioning = [SQTabbarControllerAnimatedTransitioning new]; + animatedTransitioning.fromVCIndex = fromVCIndex; + animatedTransitioning.toVCIndex = toVCIndex; + return animatedTransitioning; +} + +@end diff --git a/SQManagement/SQManagement/Main/SQTabbarControllerAnimatedTransitioning.h b/SQManagement/SQManagement/Main/SQTabbarControllerAnimatedTransitioning.h new file mode 100644 index 00000000..1716ad95 --- /dev/null +++ b/SQManagement/SQManagement/Main/SQTabbarControllerAnimatedTransitioning.h @@ -0,0 +1,21 @@ +// +// SQTabbarControllerAnimatedTransitioning.h +// SQMagnet +// +// Created by 朱双泉 on 2019/7/12. +// Copyright © 2019 Castie!. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface SQTabbarControllerAnimatedTransitioning : NSObject + +@property (nonatomic, assign) NSUInteger fromVCIndex; + +@property (nonatomic, assign) NSUInteger toVCIndex; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SQManagement/SQManagement/Main/SQTabbarControllerAnimatedTransitioning.m b/SQManagement/SQManagement/Main/SQTabbarControllerAnimatedTransitioning.m new file mode 100644 index 00000000..2e373dbb --- /dev/null +++ b/SQManagement/SQManagement/Main/SQTabbarControllerAnimatedTransitioning.m @@ -0,0 +1,40 @@ +// +// SQTabbarControllerAnimatedTransitioning.m +// SQMagnet +// +// Created by 朱双泉 on 2019/7/12. +// Copyright © 2019 Castie!. All rights reserved. +// + +#import "SQTabbarControllerAnimatedTransitioning.h" + +static CGFloat const kPadding = 10; +static CGFloat const kDamping = 0.75; +static CGFloat const kVelocity = 2; + +@implementation SQTabbarControllerAnimatedTransitioning + +- (NSTimeInterval)transitionDuration:(id)transitionContext { + return kDamping; +} + +- (void)animateTransition:(id)transitionContext { + + UIViewController * toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; + UIViewController * fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; + UIView * containerView = [transitionContext containerView]; + CGFloat translation = containerView.bounds.size.width + kPadding; + CGAffineTransform transform = CGAffineTransformMakeTranslation ((self.fromVCIndex > self.toVCIndex ? YES : NO) ? translation : -translation, 0); + toViewController.view.transform = CGAffineTransformInvert (transform); + [containerView addSubview:toViewController.view]; + + [UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0 usingSpringWithDamping:kDamping initialSpringVelocity:kVelocity options:UIViewAnimationOptionCurveEaseInOut animations:^{ + fromViewController.view.transform = transform; + toViewController.view.transform = CGAffineTransformIdentity; + } completion:^(BOOL finished) { + fromViewController.view.transform = CGAffineTransformIdentity; + [transitionContext completeTransition:![transitionContext transitionWasCancelled]]; + }]; +} + +@end diff --git a/SQManagement/SQManagement/Model/SQConnectionModel.h b/SQManagement/SQManagement/Model/SQConnectionModel.h new file mode 100644 index 00000000..3f002465 --- /dev/null +++ b/SQManagement/SQManagement/Model/SQConnectionModel.h @@ -0,0 +1,28 @@ +// +// SQConnectionModel.h +// SQManagement +// +// Created by 朱双泉 on 2019/9/28. +// Copyright © 2019 Castie!. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface SQConnectionModel : NSObject + +@property (nonatomic, copy) NSString *name; +@property (nonatomic, copy) NSString *role; +@property (nonatomic, copy) NSString *occupation; +@property (nonatomic, copy) NSString *region; +@property (nonatomic, copy) NSString *industry; +@property (nonatomic, copy) NSString *effect; +@property (nonatomic, copy) NSString *intimacy; +@property (nonatomic, copy) NSString *goldenCircle; + +- (void)map:(NSUInteger)row bind:(UIView *)view; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SQManagement/SQManagement/Model/SQConnectionModel.m b/SQManagement/SQManagement/Model/SQConnectionModel.m new file mode 100644 index 00000000..696b3a1a --- /dev/null +++ b/SQManagement/SQManagement/Model/SQConnectionModel.m @@ -0,0 +1,88 @@ +// +// SQConnectionModel.m +// SQManagement +// +// Created by 朱双泉 on 2019/9/28. +// Copyright © 2019 Castie!. All rights reserved. +// + +#import +#import "SQConnectionModel.h" + +typedef NS_ENUM(NSInteger, SQConnectionProperty) { + SQConnectionName = 0, + SQConnectionRole, + SQConnectionOccupation, + SQConnectionRegion, + SQConnectionIndustry, + SQConnectionEffect, + SQConnectionIntimacy, + SQConnectionGoldenCircle, +}; + +@implementation SQConnectionModel + +- (void)map:(NSUInteger)row bind:(UIView *)view { + switch (row) { + case SQConnectionName: + if ([view isKindOfClass:UITextField.class]) { + self.name = [view valueForKey:@"text"]; + } else if ([view isKindOfClass:UILabel.class]) { + [view setValue:self.name forKey:@"text"]; + } + break; + case SQConnectionRole: + if ([view isKindOfClass:UITextField.class]) { + self.role = [view valueForKey:@"text"]; + } else if ([view isKindOfClass:UILabel.class]) { + [view setValue:self.role forKey:@"text"]; + } + break; + case SQConnectionOccupation: + if ([view isKindOfClass:UITextField.class]) { + self.occupation = [view valueForKey:@"text"]; + } else if ([view isKindOfClass:UILabel.class]) { + [view setValue:self.occupation forKey:@"text"]; + } + break; + case SQConnectionRegion: + if ([view isKindOfClass:UITextField.class]) { + self.region = [view valueForKey:@"text"]; + } else if ([view isKindOfClass:UILabel.class]) { + [view setValue:self.region forKey:@"text"]; + } + break; + case SQConnectionIndustry: + if ([view isKindOfClass:UITextField.class]) { + self.industry = [view valueForKey:@"text"]; + } else if ([view isKindOfClass:UILabel.class]) { + [view setValue:self.industry forKey:@"text"]; + } + break; + case SQConnectionEffect: + if ([view isKindOfClass:UITextField.class]) { + self.effect = [view valueForKey:@"text"]; + } else if ([view isKindOfClass:UILabel.class]) { + [view setValue:self.effect forKey:@"text"]; + } + break; + case SQConnectionIntimacy: + if ([view isKindOfClass:UITextField.class]) { + self.intimacy = [view valueForKey:@"text"]; + } else if ([view isKindOfClass:UILabel.class]) { + [view setValue:self.intimacy forKey:@"text"]; + } + break; + case SQConnectionGoldenCircle: + if ([view isKindOfClass:UITextField.class]) { + self.goldenCircle = [view valueForKey:@"text"]; + } else if ([view isKindOfClass:UILabel.class]) { + [view setValue:self.goldenCircle forKey:@"text"]; + } + break; + default: + break; + } +} + +@end diff --git a/SQManagement/SQManagement/SQExtension/UIView+SQExtension.h b/SQManagement/SQManagement/SQExtension/UIView+SQExtension.h index 608dfcc8..0ee98a24 100644 --- a/SQManagement/SQManagement/SQExtension/UIView+SQExtension.h +++ b/SQManagement/SQManagement/SQExtension/UIView+SQExtension.h @@ -8,8 +8,6 @@ #import -NS_ASSUME_NONNULL_BEGIN - typedef void (^SQWhenTappedBlock)(void); @interface UIView (SQExtension) @@ -45,5 +43,3 @@ typedef void (^SQWhenTappedBlock)(void); - (void)loomingAnimationWithDuration:(CGFloat)duration; @end - -NS_ASSUME_NONNULL_END diff --git a/SQManagement/SQManagement/SQExtension/UIView+SQExtension.m b/SQManagement/SQManagement/SQExtension/UIView+SQExtension.m index 79d023bb..93befc73 100644 --- a/SQManagement/SQManagement/SQExtension/UIView+SQExtension.m +++ b/SQManagement/SQManagement/SQExtension/UIView+SQExtension.m @@ -114,7 +114,7 @@ - (void)setBlock:(SQWhenTappedBlock)block forKey:(void *)blockKey { /** gesture method */ - (UITapGestureRecognizer *)addTapGestureRecognizerWithTaps:(NSUInteger)taps touches:(NSUInteger)touches selector:(SEL)selector { UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:selector]; - tapGesture.delegate = self; + tapGesture.delegate = (id)self; tapGesture.numberOfTapsRequired = taps; tapGesture.numberOfTouchesRequired = touches; [self addGestureRecognizer:tapGesture]; diff --git a/SQManagement/SQManagement/SQExtension/UIViewController+SQExtension.m b/SQManagement/SQManagement/SQExtension/UIViewController+SQExtension.m index 94736f17..527de15b 100644 --- a/SQManagement/SQManagement/SQExtension/UIViewController+SQExtension.m +++ b/SQManagement/SQManagement/SQExtension/UIViewController+SQExtension.m @@ -28,7 +28,6 @@ - (UILabel *)findNavigationBarContentViewTitleLabel { - (void)navigationBarGradualChangeWithScrollView:(UIScrollView *)scrollView titleView:(UIView *)titleView movableView:(UIView *)movableView offset:(CGFloat)offset color:(UIColor *)color { [self viewWillLayoutSubviews]; - [self setAutomaticallyAdjustsScrollViewInsets:NO]; [self.navigationController.navigationBar setUserInteractionEnabled:scrollView.contentOffset.y > offset ? YES : NO]; float alpha = 1 - ((offset - scrollView.contentOffset.y) / offset); diff --git a/SQManagement/SQManagement/UI/SQAddConnectionViewController.m b/SQManagement/SQManagement/UI/SQAddConnectionViewController.m index 06e00665..4663e1e4 100644 --- a/SQManagement/SQManagement/UI/SQAddConnectionViewController.m +++ b/SQManagement/SQManagement/UI/SQAddConnectionViewController.m @@ -11,55 +11,50 @@ #import "SQConnectionPropertyCell.h" #import "UIColor+SQExtension.h" #import "UIView+SQExtension.h" +#import "SQConnectionModel.h" @interface SQAddConnectionViewController () @property (nonatomic, strong) NSArray *dataSource; @property (nonatomic, strong) SQProfileHeaderView *headerView; +@property (nonatomic, strong) SQConnectionModel *connection; @end @implementation SQAddConnectionViewController - (void)viewDidLoad { [super viewDidLoad]; - { - 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]; - }]; - } + self.title = @"新增人脉"; + self.dataSource = @[ + @[@"姓名", @"角色", @"职业", @"地区", @"行业", @"影响力", @"亲密程度", @"黄金人脉圈"], + @[@"联系方式", @"社交记录"], + @[@"特征", @"工作", @"爱好", @"特殊细节", @"给我的启发"], + ]; + self.connection = [SQConnectionModel new]; + 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 { @@ -74,15 +69,8 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { SQConnectionPropertyCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SQConnectionPropertyCell class])]; cell.titleLabel.text = self.dataSource[indexPath.section][indexPath.row]; - if (indexPath.section != 0) { - cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - cell.selectionStyle = UITableViewCellSelectionStyleGray; - cell.contentTextField.hidden = YES; - } else { - cell.accessoryType = UITableViewCellAccessoryNone; - cell.selectionStyle = UITableViewCellSelectionStyleNone; - cell.contentTextField.hidden = NO; - } + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + [self.connection map:indexPath.row bind:cell.inputLabel]; return cell; } @@ -96,6 +84,21 @@ - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSIntege return 1; } +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + if (indexPath.section == 0) { + UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:[NSString stringWithFormat:@"请输入 - %@", self.dataSource[indexPath.section][indexPath.row]] preferredStyle:(UIAlertControllerStyleAlert)]; + [alertVc addTextFieldWithConfigurationHandler:nil]; + [alertVc addAction:[UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:nil]]; + __weak typeof(alertVc) weakSelf = alertVc; + [alertVc addAction:[UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) { + [self.connection map:indexPath.row bind:weakSelf.textFields.firstObject]; + [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:(UITableViewRowAnimationNone)]; + }]]; + [self presentViewController:alertVc animated:YES completion:nil]; + } +} + - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissViewControllerAnimated:YES completion:nil]; self.headerView.profileImageView.image = [info objectForKey:UIImagePickerControllerOriginalImage]; diff --git a/SQManagement/SQManagement/UI/SQConnectionsViewController.m b/SQManagement/SQManagement/UI/SQConnectionsViewController.m index dc870aac..f0f93188 100644 --- a/SQManagement/SQManagement/UI/SQConnectionsViewController.m +++ b/SQManagement/SQManagement/UI/SQConnectionsViewController.m @@ -27,6 +27,10 @@ - (void)viewDidLoad { }]; } +- (BOOL)isShowNavigationShadowImage { + return NO; +} + - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 2; }