예제 #1
0
        private static void OnCurrentSnapshot(IDocumentSnapshot?snapshot)
        {
            Current = snapshot?.ToObject <DonorUser>();
            CurrentUpdated?.Invoke(Current);
            if (previousUID != Current?.UID)
            {
                previousUID = Current?.UID;
                CurrentChanged?.Invoke(Current);
                CrossFirebasePushNotification.Current.UnsubscribeAll();
                if (!(Current is null))
                {
                    CrossFirebasePushNotification.Current.Subscribe("Urgent_Project");
                }
            }
            _ = DonationBundle.SetCurrentAsync(Current?.CurrentDonationBundle);
            if (!(Current is null) && ThemeEngine.SetTheme(Current.DesiredTheme))
            {
                SecureStorage.SetAsync("ThemePreference", Current.DesiredTheme.ToString());
            }
            var newTopics = Current?.DonatedProjectUIDs.Select(x => "Project_" + x)
                            .Where(x => !CrossFirebasePushNotification.Current.SubscribedTopics.Contains(x));

            if (newTopics?.Any() ?? false)
            {
                CrossFirebasePushNotification.Current.Subscribe(newTopics.ToArray());
            }
            System.Diagnostics.Debug.WriteLine(string.Join(", ", CrossFirebasePushNotification.Current.SubscribedTopics));
        }
예제 #2
0
 private static void OnCurrentSnapshot(IDocumentSnapshot?snapshot)
 {
     Current = snapshot?.ToObject <PartnerUser>();
     CurrentUpdated?.Invoke(Current);
     if (Current?.UID != previousUID)
     {
         previousUID = Current?.UID;
         CurrentChanged?.Invoke(Current);
     }
     if (Current?.TeamConfirmed ?? false)
     {
         Team.SetCurrent(Current.TeamUID);
     }
     if (!(Current is null) && ThemeEngine.SetTheme(Current.DesiredTheme))
     {
         SecureStorage.SetAsync("ThemePreference", Current.DesiredTheme.ToString());
     }
 }
예제 #3
0
        protected override async void OnStart()
        {
            // Set the most likely-to-be-accurate theme before user account is loaded but not interfere with login screen theming on android
            string themePreference = await SecureStorage.GetAsync("ThemePreference");

            ThemeEngine.SetTheme(string.IsNullOrEmpty(themePreference) ? Theme.System : (Theme)Enum.Parse(typeof(Theme), themePreference),
                                 Shell.Current.CurrentState.Location.OriginalString != "//Login");

            // Check photo access permission
            try
            {
                var result = await Permissions.CheckStatusAsync <Permissions.Media>();

                if (result != PermissionStatus.Granted)
                {
                    await Permissions.RequestAsync <Permissions.Media>();
                }
            }
            catch { } // Absorb
        }