From 6fd35e9823638802bc5d0f57df865a254d29f487 Mon Sep 17 00:00:00 2001 From: Alexandre Colucci Date: Mon, 11 Nov 2024 08:30:56 +0100 Subject: [PATCH] Improve the Cross promotion window --- .../Base.lproj/ACCrossPromotionWindow.xib | 298 +----------------- .../ACCrossPromotionWindowController.h | 1 + .../ACCrossPromotionWindowController.m | 37 ++- 3 files changed, 43 insertions(+), 293 deletions(-) diff --git a/VPNStatus/Base.lproj/ACCrossPromotionWindow.xib b/VPNStatus/Base.lproj/ACCrossPromotionWindow.xib index 5a0beff..60deb0d 100644 --- a/VPNStatus/Base.lproj/ACCrossPromotionWindow.xib +++ b/VPNStatus/Base.lproj/ACCrossPromotionWindow.xib @@ -1,14 +1,14 @@ - + - - - + + + @@ -17,289 +17,24 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - @@ -307,9 +42,4 @@ - - - - - diff --git a/VPNStatus/CrossPromotion/ACCrossPromotionWindowController.h b/VPNStatus/CrossPromotion/ACCrossPromotionWindowController.h index c2756b8..f10f6e2 100644 --- a/VPNStatus/CrossPromotion/ACCrossPromotionWindowController.h +++ b/VPNStatus/CrossPromotion/ACCrossPromotionWindowController.h @@ -1,5 +1,6 @@ // // ACCrossPromotionWindowController.h +// VPNStatus // // Created by Alexandre Colucci on 16.03.2024. // Copyright © 2024 Alexandre Colucci. All rights reserved. diff --git a/VPNStatus/CrossPromotion/ACCrossPromotionWindowController.m b/VPNStatus/CrossPromotion/ACCrossPromotionWindowController.m index 0e65254..46ef067 100644 --- a/VPNStatus/CrossPromotion/ACCrossPromotionWindowController.m +++ b/VPNStatus/CrossPromotion/ACCrossPromotionWindowController.m @@ -1,11 +1,19 @@ // // ACCrossPromotionWindowController.m -// Dependencies +// VPNStatus // // Created by Alexandre Colucci on 16.03.2024. // Copyright © 2024 Alexandre Colucci. All rights reserved. #import "ACCrossPromotionWindowController.h" +#import + +@interface ACCrossPromotionWindowController () + +@property (weak) IBOutlet WKWebView *webView; + +@end + @implementation ACCrossPromotionWindowController @@ -30,19 +38,30 @@ -(instancetype)initCrossPromotionWindow return self; } --(IBAction)doDependencies:(id)sender +- (void)windowDidLoad { - [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://apps.apple.com/app/dependencies/id1538972026"]]; -} + [super windowDidLoad]; --(IBAction)doMarkChart:(id)sender -{ - [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://apps.apple.com/us/app/markchart-mermaid-preview/id6475648822"]]; + [self.webView setNavigationDelegate:self]; + NSURL *url = [NSURL URLWithString:@"https://blog.timac.org/apps"]; + NSURLRequest *request = [NSURLRequest requestWithURL: url]; + [self.webView loadRequest:request]; } --(IBAction)doVPNStatus:(id)sender +- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { - [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://github.com/Timac/VPNStatus/releases"]]; + NSURL *url = navigationAction.request.URL; + if([url.absoluteString isEqualToString:@"https://blog.timac.org/apps"]) + { + decisionHandler(WKNavigationActionPolicyAllow); + return; + } + else if(url != nil) + { + [[NSWorkspace sharedWorkspace] openURL:url]; + } + + decisionHandler(WKNavigationActionPolicyCancel); } @end