Example #1
0
 public static void GlobalRefresh(CoreConfiguration config)
 {
     CoreDependencyService.DisposeAllServices();
     CoreDependencyService.ReleaseViewModelResources();
     Config = config;
     CoreDependencyService.InitViewModelResources();
 }
Example #2
0
 public static void SaveState <T>(this T vm) where T : CoreViewModel, new()
 {
     Task.Run(async() =>
     {
         await CoreDependencyService.GetService <IFileStore, FileStore>(true)?.SaveAsync <T>(typeof(T).FullName, vm);
     });
 }
Example #3
0
 public static void GlobalRefresh()
 {
     CoreDependencyService.DisposeAllServices();
     CoreDependencyService.ReleaseViewModelResources();
     Load();
     CoreDependencyService.InitViewModelResources();
 }
Example #4
0
        public new void OnClick(Views.View v)
        {
            if (IsMasterDetail() && CoreSettings.AppNav.NavigationStack.Count <= 1)
            {
                CoreDependencyService.InvokeMasterDetailEvent();
                return;
            }

            // Call the NavigationPage which will trigger the default behavior
            // The default behavior is to navigate back if the Page derived classes return true from OnBackButtonPressed override
            var curPage = Element.CurrentPage as BasePages;

            if (curPage == null)
            {
                Element.PopAsync();
            }
            else
            {
                if (curPage.NeedOverrideSoftBackButton)
                {
                    curPage.OnSoftBackButtonPressed();
                }
                else
                {
                    Element.PopAsync();
                }
            }
        }
Example #5
0
        public static async Task <PermissionStatus> RequestPermissions(this object caller, Permission permission, string dialogTitle, string dialogMessage)
        {
            var status = await CrossPermissions.Current.CheckPermissionStatusAsync(permission);

            if (status != PermissionStatus.Granted)
            {
                if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(permission))
                {
                    CoreDependencyService.GetDependency <IDialogPrompt>().ShowMessage(new Prompt()
                    {
                        Title   = dialogTitle,
                        Message = dialogMessage
                    });
                }

                var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { permission });

#if __ANDROID__
                if (Looper.MyLooper() == null)
                {
                    Looper.Prepare();
                }
#endif
                status = results[permission];
            }

            return(status);
        }
 public static void Reload()
 {
     CoreDependencyService.DisposeServices();
     CoreDependencyService.ReleaseViewModelResources();
     Load();
     CoreDependencyService.InitViewModelResources();
 }
 public void CallEndedEvent(CTCall call)
 {
     if (TelephoneManager.IsListening && call.CallState == "CTCallStateDisconnected")
     {
         TelephoneManager.IsListening = false;
         CoreDependencyService.SendViewModelMessage(TelephoneManager.CallBackKey, true);
     }
 }
Example #8
0
 public static void LoadState <T>(this T vm) where T : CoreViewModel, new()
 {
     Task.Run(async() =>
     {
         var result = await CoreDependencyService.GetService <IFileStore, FileStore>(true)?.GetAsync <T>(typeof(T).FullName);
         if (result.Error == null)
         {
             foreach (var prop in typeof(T).GetProperties())
             {
                 prop.SetValue(vm, prop.GetValue(result.Response));
             }
         }
     });
 }
        public override void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action <UNNotificationPresentationOptions> completionHandler)
        {
            DependencyService.Get <INotificationManager>().ReceiveNotification(notification.Request.Content.Title, notification.Request.Content.Body);

            var dict = new Dictionary <string, string>();

            dict.Add("Title", notification.Request.Content.Title);
            dict.Add("Message", notification.Request.Content.Body);

            foreach (var key in notification.Request.Content.UserInfo.Keys)
            {
                dict.Add(key.ToString(), notification.Request.Content.UserInfo[key].ToString());
            }

            CoreDependencyService.SendViewModelMessage(CoreSettings.RemoteNotificationReceived, dict);

            // alerts are always shown for demonstration but this can be set to "None"
            // to avoid showing alerts if the app is in the foreground
            completionHandler(UNNotificationPresentationOptions.Alert);
        }
Example #10
0
 public CoreMasterDetailPage()
 {
     VM = CoreDependencyService.GetViewModel <T>(true);
     this.BindingContext = VM;
 }
Example #11
0
 /// <summary>
 /// Broadcast message to a particular view model instance
 /// </summary>
 /// <param name="key">Key.</param>
 /// <param name="obj">Object.</param>
 /// <typeparam name="T">The 1st type parameter.</typeparam>
 protected void SendViewMessage <T>(string key, object obj) where T : CoreViewModel
 {
     CoreDependencyService.SendViewModelMessage <T>(key, obj);
 }
Example #12
0
 /// <summary>
 /// Broadcast message to all view model instances
 /// </summary>
 /// <param name="key">Key.</param>
 /// <param name="obj">Object.</param>
 protected void SendViewMessage(string key, object obj)
 {
     CoreDependencyService.SendViewModelMessage(key, obj);
 }
Example #13
0
 public void CloseKeyboard()
 {
     CoreDependencyService.GetDependency <IKeyboardService>().Hide();
 }