From b28028ac4082842143b0f528d6bc539da6ccb419 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Thu, 21 Sep 2017 12:49:18 -0400 Subject: mega changes, including updates and X --- .../test/angular-ios9-uiwebview.patch.js | 75 +++++++++ www/lib/ionic-native-transitions/test/config.js | 149 ++++++++++++++++++ .../ionic-native-transitions/test/controller.js | 124 +++++++++++++++ www/lib/ionic-native-transitions/test/index.html | 168 +++++++++++++++++++++ www/lib/ionic-native-transitions/test/index.js | 21 +++ 5 files changed, 537 insertions(+) create mode 100644 www/lib/ionic-native-transitions/test/angular-ios9-uiwebview.patch.js create mode 100644 www/lib/ionic-native-transitions/test/config.js create mode 100644 www/lib/ionic-native-transitions/test/controller.js create mode 100644 www/lib/ionic-native-transitions/test/index.html create mode 100644 www/lib/ionic-native-transitions/test/index.js (limited to 'www/lib/ionic-native-transitions/test') diff --git a/www/lib/ionic-native-transitions/test/angular-ios9-uiwebview.patch.js b/www/lib/ionic-native-transitions/test/angular-ios9-uiwebview.patch.js new file mode 100644 index 00000000..58d8be10 --- /dev/null +++ b/www/lib/ionic-native-transitions/test/angular-ios9-uiwebview.patch.js @@ -0,0 +1,75 @@ +/** + * ================== angular-ios9-uiwebview.patch.js v1.1.1 ================== + * + * This patch works around iOS9 UIWebView regression that causes infinite digest + * errors in Angular. + * + * The patch can be applied to Angular 1.2.0 – 1.4.5. Newer versions of Angular + * have the workaround baked in. + * + * To apply this patch load/bundle this file with your application and add a + * dependency on the "ngIOS9UIWebViewPatch" module to your main app module. + * + * For example: + * + * ``` + * angular.module('myApp', ['ngRoute'])` + * ``` + * + * becomes + * + * ``` + * angular.module('myApp', ['ngRoute', 'ngIOS9UIWebViewPatch']) + * ``` + * + * + * More info: + * - https://openradar.appspot.com/22186109 + * - https://github.com/angular/angular.js/issues/12241 + * - https://github.com/driftyco/ionic/issues/4082 + * + * + * @license AngularJS + * (c) 2010-2015 Google, Inc. http://angularjs.org + * License: MIT + */ + +angular.module('ngIOS9UIWebViewPatch', ['ng']).config(['$provide', function($provide) { + 'use strict'; + + $provide.decorator('$browser', ['$delegate', '$window', function($delegate, $window) { + + if (isIOS9UIWebView($window.navigator.userAgent)) { + return applyIOS9Shim($delegate); + } + + return $delegate; + + function isIOS9UIWebView(userAgent) { + return /(iPhone|iPad|iPod).* OS 9_\d/.test(userAgent) && !/Version\/9\./.test(userAgent); + } + + function applyIOS9Shim(browser) { + var pendingLocationUrl = null; + var originalUrlFn= browser.url; + + browser.url = function() { + if (arguments.length) { + pendingLocationUrl = arguments[0]; + return originalUrlFn.apply(browser, arguments); + } + + return pendingLocationUrl || originalUrlFn.apply(browser, arguments); + }; + + window.addEventListener('popstate', clearPendingLocationUrl, false); + window.addEventListener('hashchange', clearPendingLocationUrl, false); + + function clearPendingLocationUrl() { + pendingLocationUrl = null; + } + + return browser; + } + }]); +}]); diff --git a/www/lib/ionic-native-transitions/test/config.js b/www/lib/ionic-native-transitions/test/config.js new file mode 100644 index 00000000..35aa240b --- /dev/null +++ b/www/lib/ionic-native-transitions/test/config.js @@ -0,0 +1,149 @@ +export default function ($ionicNativeTransitionsProvider, $stateProvider, $urlRouterProvider, $ionicConfigProvider) { + 'ngInject'; + $ionicNativeTransitionsProvider.setDefaultOptions({ + duration: 500, + // backInOppositeDirection: true + }); + + $ionicNativeTransitionsProvider.setDefaultTransition({ + type: 'flip', + direction: 'left' + }); + + $ionicNativeTransitionsProvider.setDefaultBackTransition({ + type: 'slide', + direction: 'right' + }); + + $ionicNativeTransitionsProvider.enable(false); + + $ionicConfigProvider.tabs.position('top'); + + $stateProvider + .state('tabs', { + url: "/tab", + abstract: true, + templateUrl: "templates/tabs.html" + }) + .state('tabs.home', { + url: "/home", + nativeTransitions: null, + views: { + 'home-tab': { + templateUrl: "templates/home.html" + } + } + }) + .state('tabs.about', { + url: "/about", + nativeTransitions: { + type: "fade" + }, + views: { + 'about-tab': { + templateUrl: "templates/about.html" + } + } + }) + .state('tabs.contact', { + url: "/contact", + nativeTransitions: { + type: "slide", + direction: "left", + fixedPixelsTop: 93 + }, + views: { + 'contact-tab': { + templateUrl: "templates/contact.html" + } + } + }) + .state('one', { + url: "/one", + nativeTransitions: { + "type": "flip", + "direction": "up" + }, + nativeTransitionsAndroid: { + "type": "flip", + "direction": "right" + }, + nativeTransitionsBackAndroid: { + "type": "slide", + "direction": "down" + }, + nativeTransitionsIOS: { + "type": "flip", + "direction": "left" + }, + nativeTransitionsWindowsPhone: { + "type": "flip", + "direction": "down" + }, + templateUrl: "templates/one.html" + }) + .state('two', { + url: "/two", + nativeTransitions: { + type: "fade" + }, + nativeTransitionsBack: null, + nativeTransitionsIOS: { + "type": "flip", + "direction": "down" // 'left|right|up|down', default 'right' (Android currently only supports left and right) + }, + templateUrl: "templates/two.html" + }) + .state('three', { + url: "/three", + nativeTransitions: { + type: "fade" + }, + nativeTransitionsAndroid: { + "type": "slide", + "direction": "up" // 'left|right|up|down', default 'right' (Android currently only supports left and right) + }, + nativeTransitionsBackAndroid: { + "type": "slide", + "direction": "up" // 'left|right|up|down', default 'right' (Android currently only supports left and right) + }, + templateUrl: "templates/three.html" + }) + .state('four', { + url: "/four?testParamUrl", + params: { + test: null + }, + templateUrl: "templates/four.html", + controller: function ($stateParams) { + 'ngInject'; + console.log('$stateParams', $stateParams); + } + }) + .state('five', { + url: "/five", + templateUrl: "templates/five.html", + controller: function ($stateParams) { + 'ngInject'; + console.log('$stateParams', $stateParams); + }, + resolve: function ($timeout, $q, $ionicPopup) { + 'ngInject'; + var deferred = $q.defer(); + $timeout(function () { + $ionicPopup.show({ + template: '', + title: 'A popup', + buttons: [ + { text: 'Cancel' } + ] + }); + deferred.reject(); + }, 1000) + return deferred.promise; + } + }); + + + $urlRouterProvider.otherwise("/tab/home"); +} diff --git a/www/lib/ionic-native-transitions/test/controller.js b/www/lib/ionic-native-transitions/test/controller.js new file mode 100644 index 00000000..a951d5f9 --- /dev/null +++ b/www/lib/ionic-native-transitions/test/controller.js @@ -0,0 +1,124 @@ +export default function ( + $scope, + $rootScope, + $log, + $ionicNativeTransitions, + $ionicModal, + $ionicPlatform, + $ionicHistory +) { + + 'ngInject'; + + var vm = this; + vm.modal = null; + vm.isEnable = $ionicNativeTransitions.isEnabled(); + vm.enable = enable; + vm.disable = disable; + vm.stateGo = stateGo; + vm.sameStateGo = sameStateGo; + vm.locationUrl = locationUrl; + vm.disableWithoutDisablingIonicTransitions = disableWithoutDisablingIonicTransitions; + vm.enableBothTransitions = enableBothTransitions; + vm.openModal = openModal; + vm.goBack = goBack; + vm.stateError = stateError; + + $scope.$on('$ionicView.loaded', function (event, data) { + console.log('$ionicView.loaded'); + }); + + $scope.$on('$ionicView.enter', function (event, data) { + console.log('$ionicView.enter'); + }); + + $rootScope.$on('ionicNativeTransitions.success', function () { + $log.info('yeah!'); + }); + + $rootScope.$on('ionicNativeTransitions.error', function () { + $log.info(':('); + }); + + $rootScope.$on('ionicNativeTransitions.beforeTransition', function () { + $log.info('Transition is about to happen'); + }); + + function openModal() { + if (vm.modal) { + vm.modal.show(); + return; + } + vm.modal = $ionicModal.fromTemplate(` + + +

Modal

+ +
+ + modal + +
+ `, { + scope: $rootScope.$new(), + }); + vm.modal.show(); + vm.modal.scope.close = () => { + console.log('modal close', JSON.stringify($ionicPlatform.$backButtonActions)) + vm.modal.remove(); + vm.modal = null; + }; + } + + function enable() { + $ionicNativeTransitions.enable(); + vm.isEnable = $ionicNativeTransitions.isEnabled(); + } + + function disable() { + $ionicNativeTransitions.enable(false); + vm.isEnable = $ionicNativeTransitions.isEnabled(); + } + + function disableWithoutDisablingIonicTransitions() { + $ionicNativeTransitions.enable(false, true); + vm.isEnable = $ionicNativeTransitions.isEnabled(); + } + + function enableBothTransitions() { + $ionicNativeTransitions.enable(true, false); + vm.isEnable = $ionicNativeTransitions.isEnabled(); + } + + function sameStateGo(reload = false) { + $ionicNativeTransitions.stateGo('tabs.home', {}, { reload }); + } + + function stateGo() { + $ionicNativeTransitions.stateGo('four', { + test: 'buyakacha!', + testParamUrl: 'hihi' + }, { + "type": "slide", + "direction": "up", // 'left|right|up|down', default 'left' (which is like 'next') + "duration": 1500, // in milliseconds (ms), default 400 + }, { + reload: true + }); + } + + function locationUrl() { + $ionicNativeTransitions.locationUrl('/three'); + } + + function goBack(count) { + console.log('count', count, $ionicHistory.viewHistory()) + $rootScope.$ionicGoBack(count); + } + + function stateError() { + $ionicNativeTransitions.stateGo('five'); + } +} diff --git a/www/lib/ionic-native-transitions/test/index.html b/www/lib/ionic-native-transitions/test/index.html new file mode 100644 index 00000000..9be76370 --- /dev/null +++ b/www/lib/ionic-native-transitions/test/index.html @@ -0,0 +1,168 @@ + + + + + + + {%=o.htmlWebpackPlugin.options.pkg.title %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% for (var chunk in o.htmlWebpackPlugin.files.chunks) { %} + + {% } %} + + + diff --git a/www/lib/ionic-native-transitions/test/index.js b/www/lib/ionic-native-transitions/test/index.js new file mode 100644 index 00000000..e7176887 --- /dev/null +++ b/www/lib/ionic-native-transitions/test/index.js @@ -0,0 +1,21 @@ +import 'ionic-sdk/release/js/ionic.bundle'; +import 'ionic-sdk/release/css/ionic.css'; +import '../dist/ionic-native-transitions.js'; +import './angular-ios9-uiwebview.patch.js'; +import Config from './config.js'; +import Controller from './controller.js'; + +let mod = angular.module('test', [ + 'ionic', + 'ui.router', + 'ionic-native-transitions', + 'ngIOS9UIWebViewPatch' +]); + +mod.config(Config); +mod.controller('MainController', Controller); +mod.run(($log) => { + $log.info('test running'); +}); + +export default mod = mod.name; -- cgit v1.2.3