Skip to content
Snippets Groups Projects
Commit d83bb7aa authored by Kateryna Kostiuk's avatar Kateryna Kostiuk
Browse files

UI: refactor welcome view

Change-Id: I166ea16c4110cd9fb8b7cef2624a0f0c333a0ac7
parent 8c64e9ad
No related branches found
No related tags found
No related merge requests found
...@@ -66,8 +66,6 @@ typedef NS_ENUM(NSInteger, ViewState) { ...@@ -66,8 +66,6 @@ typedef NS_ENUM(NSInteger, ViewState) {
@implementation RingWindowController { @implementation RingWindowController {
__unsafe_unretained IBOutlet NSLayoutConstraint* centerYQRCodeConstraint;
__unsafe_unretained IBOutlet NSLayoutConstraint* centerYWelcomeContainerConstraint;
IBOutlet NSLayoutConstraint* ringLabelTrailingConstraint; IBOutlet NSLayoutConstraint* ringLabelTrailingConstraint;
__unsafe_unretained IBOutlet NSView* welcomeContainer; __unsafe_unretained IBOutlet NSView* welcomeContainer;
__unsafe_unretained IBOutlet NSView* callView; __unsafe_unretained IBOutlet NSView* callView;
...@@ -431,10 +429,7 @@ typedef NS_ENUM(NSInteger, ViewState) { ...@@ -431,10 +429,7 @@ typedef NS_ENUM(NSInteger, ViewState) {
} }
- (IBAction)toggleQRCode:(id)sender { - (IBAction)toggleQRCode:(id)sender {
// Toggle pressed state of QRCode button [self showQRCode: qrcodeView.isHidden];
// [sender setPressed:![sender isPressed]];
bool show = qrcodeView.animator.alphaValue == 0.0f ? YES: NO;
[self showQRCode: show];
} }
/** /**
...@@ -508,18 +503,21 @@ typedef NS_ENUM(NSInteger, ViewState) { ...@@ -508,18 +503,21 @@ typedef NS_ENUM(NSInteger, ViewState) {
- (void) showQRCode:(BOOL) show - (void) showQRCode:(BOOL) show
{ {
[self updateQRCodeBackground]; [self updateQRCodeBackground];
static const NSInteger offset = 110; [qrcodeView setHidden: !show];
[NSAnimationContext beginGrouping]; qrcodeView.layer.opacity = 0.0;
NSAnimationContext.currentContext.duration = 0.5;
[[NSAnimationContext currentContext] setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]]; [NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
qrcodeView.animator.alphaValue = show ? 1.0 : 0.0; context.duration = 0.2;
[centerYQRCodeConstraint.animator setConstant: show ? offset : 0]; context.allowsImplicitAnimation = YES;
[centerYWelcomeContainerConstraint.animator setConstant:show ? -offset : 0]; context.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseOut];
[NSAnimationContext endGrouping]; [self.window layoutIfNeeded];
} completionHandler: ^{
qrcodeView.layer.opacity = 1.0;
}];
} }
-(void)themeChanged:(NSNotification *) notification { -(void)themeChanged:(NSNotification *) notification {
if (qrcodeView.animator.alphaValue == 1) { if (!qrcodeView.isHidden) {
[self updateQRCodeBackground]; [self updateQRCodeBackground];
} }
} }
...@@ -575,9 +573,7 @@ typedef NS_ENUM(NSInteger, ViewState) { ...@@ -575,9 +573,7 @@ typedef NS_ENUM(NSInteger, ViewState) {
[smartViewVC clearConversationModel]; [smartViewVC clearConversationModel];
[self changeViewTo:SHOW_WELCOME_SCREEN]; [self changeViewTo:SHOW_WELCOME_SCREEN];
[self updateRingID]; [self updateRingID];
qrcodeView.animator.alphaValue = 0.0; [qrcodeView setHidden: YES];
[centerYQRCodeConstraint.animator setConstant: 0];
[centerYWelcomeContainerConstraint.animator setConstant: 0];
QObject::disconnect(self.callState); QObject::disconnect(self.callState);
[self close]; [self close];
AppDelegate* delegate = (AppDelegate*)[[NSApplication sharedApplication] delegate]; AppDelegate* delegate = (AppDelegate*)[[NSApplication sharedApplication] delegate];
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment