]> git.cameronkatri.com Git - tweaks.git/commitdiff
Fixup hiding
authorCameron Katri <me@cameronkatri.com>
Mon, 3 Jan 2022 04:26:12 +0000 (23:26 -0500)
committerCameron Katri <me@cameronkatri.com>
Mon, 3 Jan 2022 04:26:12 +0000 (23:26 -0500)
QuickActions/Tweak.h
QuickActions/Tweak.x

index 41f64fdccd7776b114c09474ffb03cc32598068c..1c74481c0f7dec24402610097e81f756bb80686b 100644 (file)
 @property (nonatomic) BOOL rightOpen;
 @property (nonatomic) BOOL collapseLeft;
 @property (nonatomic) BOOL collapseRight;
 @property (nonatomic) BOOL rightOpen;
 @property (nonatomic) BOOL collapseLeft;
 @property (nonatomic) BOOL collapseRight;
--(CGRect)leftFrameForButton:(CSQuickActionsButton*)button;
--(CGRect)rightFrameForButton:(CSQuickActionsButton*)button;
+-(CGRect)leftFrameForButton:(CSQuickActionsButton*)button open:(BOOL)open;
+-(CGRect)rightFrameForButton:(CSQuickActionsButton*)button open:(BOOL)open;
 -(void)setDoNotDisturb:(BOOL)state;
 -(BOOL)isDNDActive;
 -(void)updateDND:(NSNotification *)notif;
 -(void)setDoNotDisturb:(BOOL)state;
 -(BOOL)isDNDActive;
 -(void)updateDND:(NSNotification *)notif;
index 79a31952727cef464c884d1b316da6a955c0c436..7e9a505f8c0a78b56d6eee0a837f78f70423566a 100644 (file)
@@ -120,27 +120,30 @@ void openApplication(NSString *bundleID)
 {
        %orig;
 
 {
        %orig;
 
-       if (self.leftOpen) {
-               self.leftOpen = !self.leftOpen;
-               for (CSQuickActionsButton *button in [self leftButtons]) {
-                       button.frame = [self leftFrameForButton:button];
-                       [button setHidden:!self.leftOpen];
-               }
-       }
-       if (self.rightOpen) {
-               self.rightOpen = !self.rightOpen;
-               for (CSQuickActionsButton *button in [self rightButtons]) {
-                       button.frame = [self rightFrameForButton:button];
-                       [button setHidden:!self.rightOpen];
-               }
-       }
+       [UIView animateWithDuration:0.25
+                                                 delay:0
+                                               options:UIViewAnimationOptionCurveEaseOut
+                                        animations:^(void){
+                                               for (CSQuickActionsButton *button in [self leftButtons])
+                                                       button.frame = [self leftFrameForButton:button open:NO];
+                                               self.leftOpen = NO;
+                                               for (CSQuickActionsButton *button in [self rightButtons])
+                                                       button.frame = [self rightFrameForButton:button open:NO];
+                                               self.rightOpen = NO;
+                                        }
+                                        completion:^(BOOL finished) {
+                                               for (CSQuickActionsButton *button in [self leftButtons])
+                                                       [button setHidden:YES];
+                                               for (CSQuickActionsButton *button in [self rightButtons])
+                                                       [button setHidden:YES];
+                     }];
 }
 
 %new
 }
 
 %new
--(CGRect)rightFrameForButton:(CSQuickActionsButton*)button
+-(CGRect)rightFrameForButton:(CSQuickActionsButton*)button open:(BOOL)open
 {
        CGRect cameraFrame = [[self cameraButton] frame];
 {
        CGRect cameraFrame = [[self cameraButton] frame];
-       if (self.rightOpen) {
+       if (open) {
                return CGRectMake(cameraFrame.origin.x,
                        cameraFrame.origin.y - ((cameraFrame.size.height * 3/4) * (button.type - 1)),
                        cameraFrame.size.width, cameraFrame.size.height);
                return CGRectMake(cameraFrame.origin.x,
                        cameraFrame.origin.y - ((cameraFrame.size.height * 3/4) * (button.type - 1)),
                        cameraFrame.size.width, cameraFrame.size.height);
@@ -150,10 +153,10 @@ void openApplication(NSString *bundleID)
 }
 
 %new
 }
 
 %new
--(CGRect)leftFrameForButton:(CSQuickActionsButton*)button
+-(CGRect)leftFrameForButton:(CSQuickActionsButton*)button open:(BOOL)open
 {
        CGRect flashlightFrame = [[self flashlightButton] frame];
 {
        CGRect flashlightFrame = [[self flashlightButton] frame];
-       if (self.leftOpen) {
+       if (open) {
                return CGRectMake(flashlightFrame.origin.x,
                        flashlightFrame.origin.y - ((flashlightFrame.size.height * 3/4) * (button.type - 1)),
                        flashlightFrame.size.width, flashlightFrame.size.height);
                return CGRectMake(flashlightFrame.origin.x,
                        flashlightFrame.origin.y - ((flashlightFrame.size.height * 3/4) * (button.type - 1)),
                        flashlightFrame.size.width, flashlightFrame.size.height);
@@ -225,13 +228,13 @@ void openApplication(NSString *bundleID)
 
        for (CSQuickActionsButton *button in [self leftButtons]) {
                [button setEdgeInsets:insets];
 
        for (CSQuickActionsButton *button in [self leftButtons]) {
                [button setEdgeInsets:insets];
-               button.frame = [self leftFrameForButton:button];
-               [button setHidden:!self.leftOpen];
+               button.frame = [self leftFrameForButton:button open:NO];
+               [button setHidden:YES];
        }
        for (CSQuickActionsButton *button in [self rightButtons]) {
                [button setEdgeInsets:insets];
        }
        for (CSQuickActionsButton *button in [self rightButtons]) {
                [button setEdgeInsets:insets];
-               button.frame = [self rightFrameForButton:button];
-               [button setHidden:!self.rightOpen];
+               button.frame = [self rightFrameForButton:button open:NO];
+               [button setHidden:YES];
        }
 
        [self updateDND:nil];
        }
 
        [self updateDND:nil];
@@ -248,7 +251,7 @@ void openApplication(NSString *bundleID)
                                                                                                options:UIViewAnimationOptionCurveEaseOut
                                                                                 animations:^(void){
                                                                                                                                for (CSQuickActionsButton *button in [self rightButtons]) {
                                                                                                options:UIViewAnimationOptionCurveEaseOut
                                                                                 animations:^(void){
                                                                                                                                for (CSQuickActionsButton *button in [self rightButtons]) {
-                                                                                                                                       button.frame = [self rightFrameForButton:button];
+                                                                                                                                       button.frame = [self rightFrameForButton:button open:self.rightOpen];
                                                                                                                                        if (self.rightOpen)
                                                                                                                                                [button setHidden:0];
                                                                                                                                }
                                                                                                                                        if (self.rightOpen)
                                                                                                                                                [button setHidden:0];
                                                                                                                                }
@@ -264,7 +267,7 @@ void openApplication(NSString *bundleID)
                                                                                                options:UIViewAnimationOptionCurveEaseOut
                                                                                 animations:^(void) {
                                                                                                                                for (CSQuickActionsButton *button in [self leftButtons]) {
                                                                                                options:UIViewAnimationOptionCurveEaseOut
                                                                                 animations:^(void) {
                                                                                                                                for (CSQuickActionsButton *button in [self leftButtons]) {
-                                                                                                                                       button.frame = [self leftFrameForButton:button];
+                                                                                                                                       button.frame = [self leftFrameForButton:button open:self.leftOpen];
                                                                                                                                        if (self.leftOpen)
                                                                                                                                                [button setHidden:0];
                                                                                                                                }
                                                                                                                                        if (self.leftOpen)
                                                                                                                                                [button setHidden:0];
                                                                                                                                }
@@ -286,7 +289,7 @@ void openApplication(NSString *bundleID)
                return;
        }
 
                return;
        }
 
-       /* This will make the CC module be correct */
+       /* This will make the flashlight module be correct */
        [self.delegate _resetIdleTimer];
        [self.delegate sendAction:[CSAction actionWithType:5]];
 
        [self.delegate _resetIdleTimer];
        [self.delegate sendAction:[CSAction actionWithType:5]];