Esempio n. 1
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            LoadApplication(new App());

            // Get possible shortcut item
            if (options != null)
            {
                LaunchedShortcutItem = options[UIApplication.LaunchOptionsShortcutItemKey] as UIApplicationShortcutItem;
            }

            // Add dynamic shortcut items
            var shortcut_continue = new UIMutableApplicationShortcutItem(ShortcutIdentifier.Continue, "Continue Book")
            {
                LocalizedSubtitle = "Continue to read you'r book",
                Icon = UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Bookmark)
            };

            var shortcut_search = new UIMutableApplicationShortcutItem(ShortcutIdentifier.Search, "Search store")
            {
                LocalizedSubtitle = "Search for a new book",
                Icon = UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Search)
            };

            // Update the application providing the initial 'dynamic' shortcut items.
            app.ShortcutItems = new UIApplicationShortcutItem[] { shortcut_continue, shortcut_search };

            return(base.FinishedLaunching(app, options));
        }
 private IReadOnlyDictionary <ShortcutType, UIApplicationShortcutIcon> createIcons()
 => new Dictionary <ShortcutType, UIApplicationShortcutIcon>
 {
     { ShortcutType.Reports, UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Time) },
     { ShortcutType.StopTimeEntry, UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Pause) },
     { ShortcutType.StartTimeEntry, UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Play) },
     { ShortcutType.ContinueLastTimeEntry, UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Play) }
 };
Esempio n. 3
0
        private void CreateDynamicShortcuts(UIApplication application)
        {
            var dynamicShortcut = new UIMutableApplicationShortcutItem(MenuActions.ShowPage3, "Dynamic - Page 3")
            {
                LocalizedSubtitle = "Open Page 3",
                Icon = UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Play)
            };

            application.ShortcutItems = new UIApplicationShortcutItem[] { dynamicShortcut };
        }
        public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
        {
            var selectedShortcutItem = ShortcutItem;

            if (selectedShortcutItem == null)
            {
                throw new InvalidProgramException("The `selectedShortcutItem` was not set.");
            }

            if (segue.Identifier == "ShortcutDetailUpdated")
            {
                // In the updated case, create a shortcut item to represent the final state of the view controller.
                UIApplicationShortcutIconType iconType = IconTypeForSelectedRow((int)PickerView.SelectedRowInComponent(0));
                var icon = UIApplicationShortcutIcon.FromType(iconType);

                var userInfo = new NSDictionary <NSString, NSObject> (AppDelegate.ApplicationShortcutUserInfoIconKey, new NSNumber(PickerView.SelectedRowInComponent(0)));
                ShortcutItem = new UIApplicationShortcutItem(selectedShortcutItem.Type, TitleTextField.Text ?? string.Empty, SubtitleTextField.Text, icon, userInfo);
            }
        }
Esempio n. 5
0
        public async Task <object> CreatePlatformIcon(IShortcutIcon shortcutIcon)
        {
            var isParseSuccessful = Enum.TryParse(shortcutIcon.IconName, out UIApplicationShortcutIconType type);

            if (!isParseSuccessful)
            {
                type = UIApplicationShortcutIconType.Favorite;
            }

            UIApplicationShortcutIcon icon = null;

            new NSObject().BeginInvokeOnMainThread(() =>
            {
                icon = UIApplicationShortcutIcon.FromType(type);
            });

            await Task.Delay(200);

            return(icon);
        }
Esempio n. 6
0
 private void CreateQuickActions()
 {
     if (TraitCollection.ForceTouchCapability == UIForceTouchCapability.Available)
     {
         var bundleIdentifier = NSBundle.MainBundle.BundleIdentifier;
         if (bundleIdentifier != null)
         {
             var shortcutItem1 = new UIApplicationShortcutItem("(com.companyname.FoodPinn).OpenFavorites", "Show Favorites", null, UIApplicationShortcutIcon.FromTemplateImageName("favorite"), null);
             var shortcutItem2 = new UIApplicationShortcutItem("(com.companyname.FoodPinn).OpenDiscover", "Discover Restaurants", null, UIApplicationShortcutIcon.FromTemplateImageName("discover"), null);
             var shortcutItem3 = new UIApplicationShortcutItem("(com.companyname.FoodPinn).NewRestaurant", "New Restaurant", null, UIApplicationShortcutIcon.FromType(UIApplicationShortcutIconType.Add), null);
             UIApplication.SharedApplication.ShortcutItems = new[] { shortcutItem1, shortcutItem2, shortcutItem3 };
         }
     }
 }
Esempio n. 7
0
 static UIApplicationShortcutIcon CreateIcon(UIApplicationShortcutIconType type)
 {
     return(UIApplicationShortcutIcon.FromType(type));
 }