public async override void ViewDidLoad() { base.ViewDidLoad(); SupportedLanguages = (await LanguageChoiceManager.GetLanguageChoices()).OrderBy((lang) => lang.Code).ToList(); Title = StringResources.common_menu_settings; TabBarController.Title = StringResources.common_menu_settings; SettingsTableView.Source = new SettingsTableViewSource(ReCreateSettings(), this, RowSelected); // Required to show the data ... SettingsTableView.ReloadData(); }
void SaveAppLanguageSelectedFromPicker(UIAlertAction _) { // Because the first element is the description if (CurrentAppLanguageID == 0) { return; } var chosen = SupportedLanguages.FirstOrDefault((lang) => lang.Id == CurrentAppLanguageID); StringResources.Culture = new CultureInfo(chosen.Code); Localize.SetLayoutDirectionByPreference(); Session.ActiveUser.AppLang = chosen.Id; Queries.SaveActiveUser(); SetTabBarTitles(); // This is required to update the settings strings to the new language. SettingsTableView.Source = new SettingsTableViewSource(ReCreateSettings(), this, RowSelected); // Required to update settings strings SettingsTableView.ReloadData(); }
protected async override void ConfigureUI() { BackingModel.Title = "Settings"; Objects = new List <SettingsDbObject>(await Database.Get <SettingsDbObject>()); var section = new TableSection(); foreach (var property in typeof(SettingsViewModel).GetProperties(BindingFlags.Public | BindingFlags.Instance)) { var type = property.PropertyType; var descAttribute = property.GetCustomAttributes(true).FirstOrDefault(a => a is DescriptionAttribute); var desc = descAttribute == null ? "" : ((DescriptionAttribute)descAttribute).Description; if (Objects.All(o => o.Key != property.Name)) { Objects.Add(new SettingsDbObject { Key = property.Name }); } var obj = Objects.First(o => o.Key == property.Name); // TODO: Set model properties if (type == typeof(string)) { section.Add(new EntryCell { Label = desc }.BindTo(EntryCell.TextProperty, property.Name)); } else if (type == typeof(int)) { section.Add(new EntryCell { Label = desc, Keyboard = Keyboard.Numeric }.BindTo(EntryCell.TextProperty, property.Name)); } else if (type == typeof(float)) { section.Add(new EntryCell { Label = desc, Keyboard = Keyboard.Numeric }.BindTo(EntryCell.TextProperty, property.Name)); } else if (type == typeof(double)) { section.Add(new EntryCell { Label = desc, Keyboard = Keyboard.Numeric }.BindTo(EntryCell.TextProperty, property.Name)); } else if (type == typeof(Uri)) { section.Add(new EntryCell { Label = desc, Keyboard = Keyboard.Url }.BindTo(EntryCell.TextProperty, property.Name)); } else if (type == typeof(MailAddress)) { section.Add(new EntryCell { Label = desc, Keyboard = Keyboard.Email }.BindTo(EntryCell.TextProperty, property.Name)); } else if (type == typeof(bool)) { section.Add(new SwitchCell { Text = desc }.BindTo(SwitchCell.OnProperty, property.Name)); } else if (type == typeof(Uri)) { section.Add(new EntryCell { Label = desc }.BindTo(EntryCell.TextProperty, property.Name)); } } Content = (Table = new SettingsTableView { Root = new TableRoot { section }, }); }
private void OnSettingsUpdated(object sender, EventArgs e) { SettingsTableView.ReloadData(); }