Skip to content
Snippets Groups Projects
Commit a8525943 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Andreas Traczyk
Browse files

UI: handle resize window for account settings

parent 918d7cfa
No related branches found
No related tags found
No related merge requests found
......@@ -52,7 +52,7 @@ const NSInteger BOOTSTRAP_SERVER_TAG = 300;
-(void) viewDidLoad {
[super viewDidLoad];
[[self view] setAutoresizingMask: NSViewMinXMargin | NSViewMaxXMargin | NSViewHeightSizable];
[[self view] setAutoresizingMask: NSViewMinXMargin | NSViewMaxXMargin];
[self updateView];
}
......
......@@ -120,7 +120,7 @@ typedef NS_ENUM(NSInteger, TagViews) {
devicesTableView.dataSource = self;
blockedContactsTableView.delegate = self;
blockedContactsTableView.dataSource= self;
[[self view] setAutoresizingMask: NSViewMinXMargin | NSViewMaxXMargin | NSViewHeightSizable];
[[self view] setAutoresizingMask: NSViewMinXMargin | NSViewMaxXMargin];
}
- (void)viewDidLoad {
......
......@@ -76,7 +76,7 @@ typedef NS_ENUM(NSInteger, TagViews) {
-(void)viewDidLoad {
[super viewDidLoad];
[[self view] setAutoresizingMask: NSViewMinXMargin | NSViewMaxXMargin | NSViewHeightSizable];
[[self view] setAutoresizingMask: NSViewMinXMargin | NSViewMaxXMargin];
[photoView setBordered:YES];
[addProfilePhotoImage setWantsLayer: YES];
[self setEditingMode:NO];
......
......@@ -93,15 +93,25 @@ CGFloat const VIEW_INSET = 20;
- (void) show {
[self.view setHidden:NO];
[self displayGeneralSettings];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateInset) name:NSWindowDidResizeNotification object:nil];
}
- (void)updateInset {
if(self.containerView.documentView.frame.size.height > (self.containerView.frame.size.height + VIEW_INSET) && self.containerView.contentInsets.bottom <= VIEW_INSET) {
return;
}
int bottomInset = self.containerView.frame.size.height - self.containerView.documentView.frame.size.height - VIEW_INSET;
self.containerView.contentInsets = NSEdgeInsetsMake(VIEW_INSET, 0, bottomInset, 0);
}
-(void)displayGeneralSettings {
self.containerView.documentView = accountGeneralVC.view;
int bottomInset = self.containerView.frame.size.height - accountGeneralVC.view.frame.size.height - VIEW_INSET;
self.containerView.contentInsets = NSEdgeInsetsMake(VIEW_INSET, 0, bottomInset, 0);
[self updateInset];
}
-(void)displayAllSettings {
-(void)displayAllSettingAndScrollToAdvanced: (BOOL) shouldScroll {
CGRect visibleRect = self.containerView.visibleRect;
CGRect settingsFrame = accountGeneralVC.view.frame;
settingsFrame.size.height = settingsFrame.size.height + accountAdvancedVC.view.frame.size.height;
NSView* container = [[NSView alloc] initWithFrame:settingsFrame];
......@@ -111,9 +121,37 @@ CGFloat const VIEW_INSET = 20;
accountGeneralVC.view.frame = generalSettingsFrame;
[container addSubview:accountGeneralVC.view];
self.containerView.documentView = container;
int bottomInset = self.containerView.frame.size.height - accountGeneralVC.view.frame.size.height - accountAdvancedVC.view.frame.size.height - VIEW_INSET;
self.containerView.contentInsets = NSEdgeInsetsMake(VIEW_INSET, 0, (bottomInset > 0) ? bottomInset : 0, 0);
[self scrollToTopScrollView: self.containerView];
//return scroll to position it was before changing scroll document view
NSPoint oldOrigin = NSMakePoint(0.0, [[self.containerView documentView] frame].size.height
- NSHeight([[self.containerView contentView] bounds])
- (NSHeight([[accountGeneralVC view] bounds])
- visibleRect.size.height));
[[self.containerView documentView] scrollPoint: oldOrigin];
if(!shouldScroll) {
[self updateInset];
return;
}
//animte scroll to advanced option
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:0.5];
NSClipView* clipView = [self.containerView contentView];
NSPoint newOrigin = NSMakePoint(0.0, accountAdvancedVC.view.frame.size.height
- visibleRect.size.height
+ VIEW_INSET);
NSPoint clipViewOrigin = [clipView bounds].origin;
clipViewOrigin.y = clipViewOrigin.y - NSHeight([[accountGeneralVC view] bounds]);
CGFloat accountHeight = NSHeight([[accountGeneralVC view] bounds]);
CGFloat visibleHeight = visibleRect.size.height;
if(accountGeneralVC.view.frame.size.height > visibleRect.size.height) {
clipViewOrigin.y = clipViewOrigin.y
+ accountGeneralVC.view.frame.size.height
- visibleRect.size.height
+ VIEW_INSET;
}
[[clipView animator] setBoundsOrigin:clipViewOrigin];
[NSAnimationContext endGrouping];
[[self.containerView documentView] scrollPoint: newOrigin];
[self updateInset];
}
-(void) scrollToTopScrollView: (NSScrollView *) scrollView {
......@@ -121,10 +159,9 @@ CGFloat const VIEW_INSET = 20;
if ([[scrollView documentView] isFlipped]) {
newScrollOrigin=NSMakePoint(0.0,0.0);
} else {
newScrollOrigin=NSMakePoint(0.0,NSMaxY([[scrollView documentView] frame])
newScrollOrigin=NSMakePoint(0.0, NSMaxY([[ self.containerView documentView] frame])
-NSHeight([[scrollView contentView] bounds]));
}
[[scrollView documentView] scrollPoint:newScrollOrigin];
}
......@@ -133,7 +170,7 @@ CGFloat const VIEW_INSET = 20;
-(void) updateFrame {
if (accountAdvancedVC.view.superview == self.containerView.documentView) {
[self displayAllSettings];
[self displayAllSettingAndScrollToAdvanced: NO];
return;
}
[self displayGeneralSettings];
......@@ -144,11 +181,13 @@ CGFloat const VIEW_INSET = 20;
[self displayGeneralSettings];
return;
}
[self displayAllSettings];
[self displayAllSettingAndScrollToAdvanced: YES];
}
- (void) hide {
[self.view setHidden:YES];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResizeNotification object:nil];
}
@end
......@@ -522,6 +522,8 @@
<constraint firstItem="Y8L-GO-1Qy" firstAttribute="top" secondItem="dOT-gX-qDn" secondAttribute="bottom" constant="15" id="Qyx-Mb-U5a"/>
<constraint firstItem="pzl-nx-92N" firstAttribute="top" secondItem="hsy-0z-bp6" secondAttribute="bottom" constant="15" id="Sff-Zn-zbU"/>
<constraint firstItem="dOT-gX-qDn" firstAttribute="top" secondItem="pzl-nx-92N" secondAttribute="bottom" constant="20" id="T2X-WC-rFy"/>
<constraint firstAttribute="bottom" secondItem="ODP-YD-5vy" secondAttribute="bottom" constant="20" id="TsA-3f-VGs"/>
<constraint firstItem="Y8L-GO-1Qy" firstAttribute="leading" secondItem="h5N-dv-68N" secondAttribute="leading" constant="20" id="Wgo-JG-hSY"/>
<constraint firstItem="h3Q-Fn-uye" firstAttribute="leading" secondItem="oVO-wj-fwQ" secondAttribute="trailing" constant="32" id="ZRY-Rq-HKF"/>
<constraint firstItem="pzl-nx-92N" firstAttribute="leading" secondItem="h5N-dv-68N" secondAttribute="leading" constant="20" id="ZdS-4M-DNc"/>
<constraint firstItem="ODP-YD-5vy" firstAttribute="centerX" secondItem="h5N-dv-68N" secondAttribute="centerX" id="aP4-Wz-IvA"/>
......
......@@ -250,6 +250,7 @@
<constraint firstItem="Ea1-ID-rxj" firstAttribute="bottom" secondItem="cvm-qM-aoy" secondAttribute="bottom" id="75b-Qt-rqb"/>
<constraint firstItem="WoC-F4-XLw" firstAttribute="trailing" secondItem="cvm-qM-aoy" secondAttribute="trailing" id="85b-DJ-fCv"/>
<constraint firstItem="qfH-eV-TPl" firstAttribute="top" secondItem="sfm-zu-uhe" secondAttribute="bottom" constant="15" id="9uW-jk-Cag"/>
<constraint firstItem="z9N-MQ-FzB" firstAttribute="top" secondItem="Xyb-xK-fCS" secondAttribute="bottom" constant="34" id="A6L-ah-jLi"/>
<constraint firstItem="Ea1-ID-rxj" firstAttribute="leading" secondItem="ckx-3i-KaD" secondAttribute="leading" id="CqI-mX-kxu"/>
<constraint firstItem="cvm-qM-aoy" firstAttribute="trailing" secondItem="tdn-5e-eJN" secondAttribute="trailing" id="Fdh-2r-oKB"/>
<constraint firstAttribute="bottom" secondItem="z9N-MQ-FzB" secondAttribute="bottom" constant="20" id="GDQ-g5-6om"/>
......@@ -276,6 +277,7 @@
<constraint firstItem="Cle-2S-w1n" firstAttribute="top" secondItem="J8z-Zq-1nD" secondAttribute="top" id="YR8-6T-z1S"/>
<constraint firstItem="kve-vV-IWV" firstAttribute="leading" secondItem="Nse-Qd-hDc" secondAttribute="leading" id="aH7-lG-iel"/>
<constraint firstItem="7SA-JB-crf" firstAttribute="leading" secondItem="ckx-3i-KaD" secondAttribute="leading" id="aLz-Ke-7le"/>
<constraint firstAttribute="bottom" secondItem="z9N-MQ-FzB" secondAttribute="bottom" constant="20" id="bJn-Ox-FqL"/>
<constraint firstItem="qfH-eV-TPl" firstAttribute="leading" secondItem="WoC-F4-XLw" secondAttribute="leading" id="be8-8K-3pO"/>
<constraint firstItem="bZE-aV-Yc6" firstAttribute="leading" secondItem="WoC-F4-XLw" secondAttribute="leading" id="ccm-PO-nfx"/>
<constraint firstItem="CL9-nX-XME" firstAttribute="top" secondItem="J8z-Zq-1nD" secondAttribute="bottom" constant="20" id="dXZ-Ca-XkN"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment