Ejemplo n.º 1
0
 public static void GlobalRefresh(CoreConfiguration config)
 {
     CoreDependencyService.DisposeAllServices();
     CoreDependencyService.ReleaseViewModelResources();
     Config = config;
     CoreDependencyService.InitViewModelResources();
 }
Ejemplo n.º 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);
     });
 }
Ejemplo n.º 3
0
 public static void GlobalRefresh()
 {
     CoreDependencyService.DisposeAllServices();
     CoreDependencyService.ReleaseViewModelResources();
     Load();
     CoreDependencyService.InitViewModelResources();
 }
Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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));
             }
         }
     });
 }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
 public CoreMasterDetailPage()
 {
     VM = CoreDependencyService.GetViewModel <T>(true);
     this.BindingContext = VM;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 13
0
 public void CloseKeyboard()
 {
     CoreDependencyService.GetDependency <IKeyboardService>().Hide();
 }