Beispiel #1
0
        private void OnTopicsLoaded(object sender, EventArgs e)
        {
            Task.Run(async() =>
            {
                using (var db = new DbUtil())
                {
                    var config = await CurrentUserUtil.GetCurrentUserConfigurationAsync();
                    ModulesLookup moduleLookup = null;
                    if (config != null && config.CurrentTopicId != null && (Topics?.Any(i => i.ModuleLookupId == config.CurrentTopicId) ?? false))
                    {
                        moduleLookup = await db.AsyncConnection.FindAsync <ModulesLookup>(i => i.ModuleLookupId == config.CurrentTopicId);
                    }
                    else
                    {
                        moduleLookup = Topics?.Where(i => i.Date.HasValue && i.Date.Value.Date == DateTime.Now.Date).FirstOrDefault() ?? Topics?.FirstOrDefault();
                    }

                    if (moduleLookup != null)
                    {
                        await db.AsyncConnection.GetChildrenAsync(moduleLookup, recursive: true);
                    }
                    SelectedModulesLookup = moduleLookup;
                }
            });
        }
Beispiel #2
0
        public App()
        {
            if (Device.RuntimePlatform == Device.Android)
            {
                Task.Run(async() =>
                {
                    var config = await CurrentUserUtil.GetCurrentUserConfigurationAsync();
                    if (config.AppTheme == 1)
                    {
                        Current.Resources = new DarkTheme();
                        AppTheme          = Themes.Dark;
                    }
                });
            }


            InitializeComponent();

            System.Diagnostics.Debug.WriteLine("====== resource debug info =========");
            var assembly = typeof(App).GetTypeInfo().Assembly;

            foreach (var res in assembly.GetManifestResourceNames())
            {
                System.Diagnostics.Debug.WriteLine("found resource: " + res);
            }
            System.Diagnostics.Debug.WriteLine("====================================");

            if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Android)
            {
                var local = DependencyService.Get <ILocalize>();
                var ci    = local.GetCurrentCultureInfo();
                StringResources.Culture = ci;
                local.SetLocale(ci);
            }

            RegisterDependencies();

            RegisterPages();

            Task.Run(async() => await DbUtil.InitDbAsync(new string[] { "Grace2020.Models.Tables" }));

            MainPage = new AppShell();
        }
Beispiel #3
0
        protected override async Task LoadItems()
        {
            var webService = new WebService();
            await webService.GetModulesAsync();

            var config = await CurrentUserUtil.GetCurrentUserConfigurationAsync();

            if (config?.CurrentTopicId != null)
            {
                JumpBackInEnabled = true;
                RaisePropertyChanged(nameof(JumpBackInEnabled));
            }
            var modules = new List <Module> {
                new Module {
                    ModuleName = StringResources.PrayerModules
                }
            };

            modules.AddRange(await LoadModelsAsync <Module>());
            Modules = new ObservableCollection <Module>(modules);
        }
Beispiel #4
0
        public ModulesVM()
        {
            NavigateToPrayerHome = new RelayCommand <Module>(async(module) =>
            {
                if (module.ModuleName != StringResources.PrayerModules)
                {
                    await CurrentUserUtil.UpdateCurrentUserConfigAsync(module?.ModuleId);
                    var vm = new PrayerHomeVM(module);
                    NavigationService.GoTo("///Home", vm);
                    await vm.Load();
                }
            });

            JumpBackIn = new RelayCommand(async() =>
            {
                var config = await CurrentUserUtil.GetCurrentUserConfigurationAsync();
                if (config?.CurrentTopicId != null)
                {
                    using (var db = new DbUtil())
                    {
                        var moduleLookup = await db.AsyncConnection.FindAsync <ModulesLookup>(i => i.ModuleLookupId == config.CurrentTopicId);
                        var vm           = new PrayerHomeVM(moduleLookup);
                        if (IsBackNavEnabled)
                        {
                            NavigationService.GoTo("..");
                        }
                        else
                        {
                            NavigationService.GoTo("///Home", vm);
                        }

                        await vm.Load();
                    }
                }
            });
        }