diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..386f826 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +# Release notes + +## 0.6.6 + +* Removed support for Windows Phone 8 +* Fixed iOS version for Apple's ITMS-90809: UIWebView API Deprecation diff --git a/README.md b/README.md index 4a8f285..ffc8341 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,25 @@ -## Native Page Transitions Cordova / PhoneGap Plugin -by [Telerik](http://www.telerik.com) +# Native Page Transitions Cordova / PhoneGap Plugin -> **WARNING**: This plugin is no longer maintained, and we now recommend using [NativeScript](https://www.nativescript.org/) as you get native transitions (and UI) out of the box. +## Aknowledgments + +This is a fork of now unmaintained plugin by [Telerik](https://github.com/Telerik-Verified-Plugins/NativePageTransitions) + +## Fixes since Telerik last version (0.6.5) + +* ITMS-90809: UIWebView API Deprecation + +## Installation Using the Cordova CLI? ``` -cordova plugin add com.telerik.plugins.nativepagetransitions +cordova plugin add cordova-plugin-nativepagetransitions ``` Using PGB? ```xml - + ``` [The MIT License (MIT)](http://www.opensource.org/licenses/mit-license.html) diff --git a/package.json b/package.json index 24465b7..ab55cd4 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,11 @@ { - "version": "0.6.5", - "name": "com.telerik.plugins.nativepagetransitions", + "version": "0.6.6", + "name": "cordova-plugin-nativepagetransitions", "cordova_name": "Native Page Transitions", "description": "Slide out the current page to reveal the next one. By a native transitions.", "license": "MIT", - "author": "Telerik / Eddy Verbruggen (https://github.com/EddyVerbruggen)", - "repo": "https://github.com/Telerik-Verified-Plugins/WKWebView.git", - "issue": "https://github.com/Telerik-Verified-Plugins/WKWebView/issues", + "author": "Original version by Telerik / Eddy Verbruggen (https://github.com/EddyVerbruggen)", + "repo": "https://github.com/tlacroix/NativePageTransitions.git", "keywords": [ "Native transitions", "Native page transitions", @@ -17,15 +16,11 @@ "Curl", "ecosystem:cordova", "cordova-android", - "cordova-ios", - "cordova-wp8", - "cordova-windows" + "cordova-ios" ], "platforms": [ "ios", - "android", - "wp8", - "windows" + "android" ], "engines": [ { diff --git a/plugin.xml b/plugin.xml index a74b56d..0c2c7cf 100755 --- a/plugin.xml +++ b/plugin.xml @@ -1,28 +1,17 @@ - - + Native Page Transitions - - - Slide out the current page to reveal the next one. By a native transitions. - - - Eddy Verbruggen / Telerik - + Slide out the current page to reveal the next one. By a native transitions. + + Eddy Verbruggen / Telerik + Tommy Lacroix / NuageLab + MIT - Native transitions, Native page transitions, Slide, Flip, Drawer, Menu, Curl - - https://github.com/Telerik-Verified-Plugins/NativePageTransitions.git - - https://github.com/Telerik-Verified-Plugins/NativePageTransitions/issues - + https://github.com/tlacroix/NativePageTransitions.git - @@ -45,7 +34,7 @@ - + @@ -53,14 +42,14 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/src/ios/NativePageTransitions.m b/src/ios/NativePageTransitions.m index 0645167..ebcb044 100644 --- a/src/ios/NativePageTransitions.m +++ b/src/ios/NativePageTransitions.m @@ -718,10 +718,6 @@ - (UIImage*) grabScreenshot { } - (BOOL) loadHrefIfPassed:(NSString*) href { - UIWebView *uiwebview = nil; - if ([self.webView isKindOfClass:[UIWebView class]]) { - uiwebview = ((UIWebView*)self.webView); - } if (href != nil && ![href isEqual:[NSNull null]]) { if (![href hasPrefix:@"#"]) { // strip any params when looking for the file on the filesystem @@ -735,11 +731,7 @@ - (BOOL) loadHrefIfPassed:(NSString*) href { } NSURL *url; NSURL *origUrl; - if (self.wkWebView != nil) { - origUrl = self.wkWebView.URL; - } else { - origUrl = uiwebview.request.URL; - } + origUrl = self.wkWebView.URL; if([origUrl.scheme isEqualToString:@"file"]) { NSString *currentUrl = origUrl.absoluteString; NSRange lastSlash = [currentUrl rangeOfString:@"/" options:NSBackwardsSearch]; @@ -761,12 +753,7 @@ - (BOOL) loadHrefIfPassed:(NSString*) href { NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url]; - // Utilize WKWebView for request if it exists - if (self.wkWebView != nil) { - [self.wkWebView loadRequest: urlRequest]; - } else { - [uiwebview loadRequest: urlRequest]; - } + [self.wkWebView loadRequest: urlRequest]; } else if (![href hasPrefix:@"#"]) { CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"href must be null, a .html file or a #navigationhash"]; [self.commandDelegate sendPluginResult:pluginResult callbackId:_command.callbackId]; @@ -774,11 +761,7 @@ - (BOOL) loadHrefIfPassed:(NSString*) href { } else { // it's a hash, so load the url without any possible current hash NSString *url = nil; - if (self.wkWebView != nil) { - url = self.wkWebView.URL.absoluteString; - } else { - url = uiwebview.request.URL.absoluteString; - } + url = self.wkWebView.URL.absoluteString; // remove the # if it's still there if ([url rangeOfString:@"#"].location != NSNotFound) { @@ -790,11 +773,7 @@ - (BOOL) loadHrefIfPassed:(NSString*) href { // and load it NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:url]]; - if (self.wkWebView != nil) { - [self.wkWebView loadRequest: urlRequest]; - } else { - [uiwebview loadRequest: urlRequest]; - } + [self.wkWebView loadRequest: urlRequest]; } } return YES; diff --git a/src/winphone/NativePageTransitions.cs b/src/winphone/NativePageTransitions.cs deleted file mode 100644 index 3c2baf1..0000000 --- a/src/winphone/NativePageTransitions.cs +++ /dev/null @@ -1,340 +0,0 @@ -using Microsoft.Phone.Tasks; -using Microsoft.Phone.Controls; -using WPCordovaClassLib.Cordova; -using WPCordovaClassLib.Cordova.Commands; -using WPCordovaClassLib.Cordova.JSON; -using System.Runtime.Serialization; -using System; -using System.ComponentModel; -using System.IO; -using System.Threading; -using System.Windows; -using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Media.Imaging; -using System.Windows.Controls; -using System.Windows.Controls.Primitives; -using System.Windows.Navigation; -using WPCordovaClassLib; -using Microsoft.Xna.Framework.Media; - -namespace Cordova.Extension.Commands -{ - public class NativePageTransitions : BaseCommand - { - - public NativePageTransitions() - { - cView = getCordovaView(); - browser = cView.Browser; - //browser.Navigated += Browser_Navigated; - //browser.Navigating += Browser_Navigating; - img = new Image(); - } - - [DataContract] - public class TransitionOptions - { - [DataMember(IsRequired = true, Name = "direction")] - public string direction { get; set; } - - [DataMember(IsRequired = true, Name = "duration")] - public int duration { get; set; } - - [DataMember(IsRequired = false, Name = "slowdownfactor")] - public int slowdownfactor { get; set; } - - [DataMember(IsRequired = false, Name = "href")] - public string href { get; set; } - - [DataMember(IsRequired = false, Name = "winphonedelay")] - public int winphonedelay { get; set; } - } - - private CordovaView cView; - private WebBrowser browser; - private TransitionOptions transitionOptions; - private Image img; - private Image img2; - - public void slide(string options) - { - try - { - String jsonOptions = JsonHelper.Deserialize(options)[0]; - transitionOptions = JsonHelper.Deserialize(jsonOptions); - } - catch (Exception) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); - return; - } - - Deployment.Current.Dispatcher.BeginInvoke(() => - { - // grab a screenshot - WriteableBitmap bmp = new WriteableBitmap(browser, null); - var width = (int)bmp.PixelWidth; - var height = (int)bmp.PixelHeight; - - img.Source = bmp; - - img2 = new Image(); - img2.Source = bmp; - - // image animation - img2.RenderTransform = new TranslateTransform(); - DoubleAnimation imgAnimation = new DoubleAnimation(); - imgAnimation.Duration = TimeSpan.FromMilliseconds(transitionOptions.duration); - - string animationAxis = "X"; - double webviewAnimationFrom = 0; - int screenshotSlowdownFactor = 1; - int webviewSlowdownFactor = 1; - int imgOrdering = 0; - - if (transitionOptions.slowdownfactor < 0) { - transitionOptions.slowdownfactor = 1000; - } - - if (transitionOptions.direction == "left") - { - screenshotSlowdownFactor = transitionOptions.slowdownfactor; - webviewAnimationFrom = width; - imgAnimation.To = -width / screenshotSlowdownFactor; // Application.Current.Host.Content.ActualWidth; - } - else if (transitionOptions.direction == "right") - { - webviewSlowdownFactor = transitionOptions.slowdownfactor; - webviewAnimationFrom = -width; - imgAnimation.To = width; // Application.Current.Host.Content.ActualWidth; - imgOrdering = 1; - } - else if (transitionOptions.direction == "up") - { - animationAxis = "Y"; - screenshotSlowdownFactor = transitionOptions.slowdownfactor; - webviewAnimationFrom = height; - imgAnimation.To = -height / screenshotSlowdownFactor; // Application.Current.Host.Content.ActualHeight; - } - else if (transitionOptions.direction == "down") - { - animationAxis = "Y"; - webviewSlowdownFactor = transitionOptions.slowdownfactor; - webviewAnimationFrom = -height; - imgAnimation.To = height; // Application.Current.Host.Content.ActualHeight; - imgOrdering = 1; - } - - // inserting the image at index 0 makes it appear below the webview, - // but we need to set it to 1 first so the webview is hidden and can be updated - cView.LayoutRoot.Children.Insert(1, img); - cView.LayoutRoot.Children.Insert(imgOrdering, img2); - - - // now load the new content - if (transitionOptions.href != null && transitionOptions.href != "" && transitionOptions.href != "null") - { - String to = transitionOptions.href; - Uri currenturi = browser.Source; - string path = currenturi.OriginalString; - if (to.StartsWith("#")) - { - if (path.StartsWith("//")) - { - path = path.Substring(2); - } - if (path.Contains("#")) - { - path = path.Substring(0, path.IndexOf("#")); - } - to = path + to; - } - else - { - to = path.Substring(0, path.LastIndexOf('/')+1) + to; - } - browser.Navigate(new Uri(to, UriKind.RelativeOrAbsolute)); - } - - Storyboard.SetTarget(imgAnimation, img2); - Storyboard.SetTargetProperty(imgAnimation, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform." + animationAxis + ")")); - - - browser.RenderTransform = new TranslateTransform(); - DoubleAnimation webviewAnimation = new DoubleAnimation(); - webviewAnimation.Duration = TimeSpan.FromMilliseconds(transitionOptions.duration); - webviewAnimation.From = webviewAnimationFrom / webviewSlowdownFactor; - webviewAnimation.To = 0; - Storyboard.SetTarget(webviewAnimation, browser); - Storyboard.SetTargetProperty(webviewAnimation, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform." + animationAxis + ")")); - - - Storyboard storyboard = new Storyboard(); - storyboard.Completed += slideAnimationCompleted; - storyboard.Children.Add(imgAnimation); - storyboard.Children.Add(webviewAnimation); - - this.Perform(delegate() - { - cView.LayoutRoot.Children.Remove(img); - storyboard.Begin(); - }, transitionOptions.winphonedelay); - }); - } - - - public void flip(string options) - { - try - { - String jsonOptions = JsonHelper.Deserialize(options)[0]; - transitionOptions = JsonHelper.Deserialize(jsonOptions); - } - catch (Exception) - { - DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); - return; - } - - Deployment.Current.Dispatcher.BeginInvoke(() => - { - // grab a screenshot - WriteableBitmap bmp = new WriteableBitmap(browser, null); - - img2 = new Image(); - img2.Source = bmp; - - int direction = 1; - DependencyProperty property = PlaneProjection.RotationYProperty; - - if (transitionOptions.direction == "right") - { - direction = -1; - } - else if (transitionOptions.direction == "up") - { - property = PlaneProjection.RotationXProperty; - direction = -1; - } - else if (transitionOptions.direction == "down") - { - property = PlaneProjection.RotationXProperty; - } - - // Insert the screenshot above the webview (index 1) - cView.LayoutRoot.Children.Insert(1, img2); - - // now load the new content - if (transitionOptions.href != null && transitionOptions.href != "" && transitionOptions.href != "null") - { - String to = transitionOptions.href; - Uri currenturi = browser.Source; - string path = currenturi.OriginalString; - if (to.StartsWith("#")) - { - if (path.StartsWith("//")) - { - path = path.Substring(2); - } - if (path.Contains("#")) - { - path = path.Substring(0, path.IndexOf("#")); - } - to = path + to; - } - else - { - to = path.Substring(0, path.LastIndexOf('/')+1) + to; - } - browser.Navigate(new Uri(to, UriKind.RelativeOrAbsolute)); - } - - TimeSpan duration = TimeSpan.FromMilliseconds(transitionOptions.duration); - Storyboard sb = new Storyboard(); - sb.Completed += flipAnimationCompleted; - - // animation for the screenshot - DoubleAnimation imgAnimation = new DoubleAnimation() - { - From = 0, - To = direction * 180, - Duration = new Duration(duration) - }; - Storyboard.SetTargetProperty(imgAnimation, new PropertyPath(property)); - img2.Projection = new PlaneProjection(); - Storyboard.SetTarget(imgAnimation, img2.Projection); - sb.Children.Add(imgAnimation); - - // animation for the webview - DoubleAnimation webviewAnimation = new DoubleAnimation() - { - From = direction * -180, - To = 0, - Duration = new Duration(duration) - }; - Storyboard.SetTargetProperty(webviewAnimation, new PropertyPath(property)); - browser.Projection = new PlaneProjection(); - Storyboard.SetTarget(webviewAnimation, browser.Projection); - sb.Children.Add(webviewAnimation); - - // perform the transition after the specified delay - this.Perform(delegate() - { - // remove the image halfway down the transition so we don't see the back of the image instead of the webview - this.Perform(delegate() - { - Deployment.Current.Dispatcher.BeginInvoke(() => - { - CordovaView cView2 = getCordovaView(); - cView2.LayoutRoot.Children.Remove(img2); - }); - }, transitionOptions.duration / 2); - - sb.Begin(); - }, transitionOptions.winphonedelay); - }); - } - - // clean up resources - private void slideAnimationCompleted(object sender, EventArgs e) - { - (sender as Storyboard).Completed -= slideAnimationCompleted; - Deployment.Current.Dispatcher.BeginInvoke(() => - { - CordovaView cView = getCordovaView(); - cView.LayoutRoot.Children.Remove(img2); - }); - DispatchCommandResult(new PluginResult(PluginResult.Status.OK)); - } - - private void flipAnimationCompleted(object sender, EventArgs e) - { - (sender as Storyboard).Completed -= flipAnimationCompleted; - DispatchCommandResult(new PluginResult(PluginResult.Status.OK)); - } - - void Browser_Navigated(object sender, NavigationEventArgs e) - { - } - - void Browser_Navigating(object sender, NavigationEventArgs e) - { - } - - private CordovaView getCordovaView() - { - PhoneApplicationFrame frame = (PhoneApplicationFrame)Application.Current.RootVisual; - PhoneApplicationPage page = (PhoneApplicationPage)frame.Content; - return (CordovaView)page.FindName("CordovaView"); - } - - private void Perform(Action myMethod, int delayInMilliseconds) - { - BackgroundWorker worker = new BackgroundWorker(); - worker.DoWork += (s, e) => Thread.Sleep(delayInMilliseconds); - worker.RunWorkerCompleted += (s, e) => myMethod.Invoke(); - worker.RunWorkerAsync(); - } - } -} \ No newline at end of file