private void Init() { EditItem = new EditLoginToolBarItem(this, _loginId); ToolbarItems.Add(EditItem); if (Device.OS == TargetPlatform.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this)); } // Name var nameCell = new LabeledValueCell(AppResources.Name); nameCell.Value.SetBinding <VaultViewLoginPageModel>(Label.TextProperty, s => s.Name); // Username UsernameCell = new LabeledValueCell(AppResources.Username, button1Text: AppResources.Copy); UsernameCell.Value.SetBinding <VaultViewLoginPageModel>(Label.TextProperty, s => s.Username); UsernameCell.Value.SetBinding <VaultViewLoginPageModel>(Label.FontSizeProperty, s => s.UsernameFontSize); UsernameCell.Button1.Command = new Command(() => Copy(Model.Username, AppResources.Username)); // Password PasswordCell = new LabeledValueCell(AppResources.Password, button1Text: string.Empty, button2Text: AppResources.Copy); PasswordCell.Value.SetBinding <VaultViewLoginPageModel>(Label.TextProperty, s => s.MaskedPassword); PasswordCell.Value.SetBinding <VaultViewLoginPageModel>(Label.FontSizeProperty, s => s.PasswordFontSize); PasswordCell.Button1.SetBinding <VaultViewLoginPageModel>(Button.ImageProperty, s => s.ShowHideImage); if (Device.OS == TargetPlatform.iOS) { PasswordCell.Button1.Margin = new Thickness(10, 0); } PasswordCell.Button1.Command = new Command(() => Model.RevealPassword = !Model.RevealPassword); PasswordCell.Button2.Command = new Command(() => Copy(Model.Password, AppResources.Password)); PasswordCell.Value.FontFamily = Device.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier"); // URI UriCell = new LabeledValueCell(AppResources.Website, button1Text: AppResources.Launch); UriCell.Value.SetBinding <VaultViewLoginPageModel>(Label.TextProperty, s => s.UriHost); UriCell.Button1.SetBinding <VaultViewLoginPageModel>(IsVisibleProperty, s => s.ShowLaunch); UriCell.Button1.Command = new Command(() => Device.OpenUri(new Uri(Model.Uri))); // Notes var notesCell = new LabeledValueCell(); notesCell.Value.SetBinding <VaultViewLoginPageModel>(Label.TextProperty, s => s.Notes); notesCell.Value.LineBreakMode = LineBreakMode.WordWrap; LoginInformationSection = new TableSection(AppResources.LoginInformation) { nameCell }; NotesSection = new TableSection(AppResources.Notes) { notesCell }; Table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = true, HasUnevenRows = true, EnableSelection = false, Root = new TableRoot { LoginInformationSection, NotesSection } }; if (Device.OS == TargetPlatform.iOS) { Table.RowHeight = -1; Table.EstimatedRowHeight = 70; } else if (Device.OS == TargetPlatform.Android) { // NOTE: This is going to cause problems with i18n strings since various languages have difference string sizes PasswordCell.Button1.WidthRequest = 40; PasswordCell.Button2.WidthRequest = 59; UsernameCell.Button1.WidthRequest = 59; UriCell.Button1.WidthRequest = 75; } Title = AppResources.ViewLogin; Content = Table; BindingContext = Model; }
private void Init() { EditItem = new EditLoginToolBarItem(this, _loginId); ToolbarItems.Add(EditItem); if (Device.RuntimePlatform == Device.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this)); } // Name var nameCell = new LabeledValueCell(AppResources.Name); nameCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.Name)); // Username UsernameCell = new LabeledValueCell(AppResources.Username, button1Text: AppResources.Copy); UsernameCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.Username)); UsernameCell.Button1.Command = new Command(() => Copy(Model.Username, AppResources.Username)); UsernameCell.Value.LineBreakMode = LineBreakMode.WordWrap; // Password PasswordCell = new LabeledValueCell(AppResources.Password, button1Text: string.Empty, button2Text: AppResources.Copy); PasswordCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.MaskedPassword)); PasswordCell.Button1.SetBinding(Button.ImageProperty, nameof(VaultViewLoginPageModel.ShowHideImage)); if (Device.RuntimePlatform == Device.iOS) { PasswordCell.Button1.Margin = new Thickness(10, 0); } PasswordCell.Button1.Command = new Command(() => Model.RevealPassword = !Model.RevealPassword); PasswordCell.Button2.Command = new Command(() => Copy(Model.Password, AppResources.Password)); PasswordCell.Value.FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", WinPhone: "Courier"); PasswordCell.Value.LineBreakMode = LineBreakMode.WordWrap; // URI UriCell = new LabeledValueCell(AppResources.Website, button1Text: AppResources.Launch); UriCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.UriHost)); UriCell.Button1.SetBinding(IsVisibleProperty, nameof(VaultViewLoginPageModel.ShowLaunch)); UriCell.Button1.Command = new Command(() => { if (Device.RuntimePlatform == Device.Android && Model.Uri.StartsWith("androidapp://")) { MessagingCenter.Send(Application.Current, "LaunchApp", Model.Uri); } else if (Model.Uri.StartsWith("http://") || Model.Uri.StartsWith("https://")) { Device.OpenUri(new Uri(Model.Uri)); } }); // Totp TotpCodeCell = new LabeledValueCell(AppResources.VerificationCodeTotp, button1Text: AppResources.Copy, subText: "--"); TotpCodeCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.TotpCodeFormatted)); TotpCodeCell.Value.SetBinding(Label.TextColorProperty, nameof(VaultViewLoginPageModel.TotpColor)); TotpCodeCell.Button1.Command = new Command(() => Copy(Model.TotpCode, AppResources.VerificationCodeTotp)); TotpCodeCell.Sub.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.TotpSecond)); TotpCodeCell.Sub.SetBinding(Label.TextColorProperty, nameof(VaultViewLoginPageModel.TotpColor)); TotpCodeCell.Value.FontFamily = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", WinPhone: "Courier"); // Notes NotesCell = new LabeledValueCell(); NotesCell.Value.SetBinding(Label.TextProperty, nameof(VaultViewLoginPageModel.Notes)); NotesCell.Value.LineBreakMode = LineBreakMode.WordWrap; LoginInformationSection = new TableSection(AppResources.LoginInformation) { nameCell }; NotesSection = new TableSection(AppResources.Notes) { NotesCell }; Table = new ExtendedTableView { Intent = TableIntent.Settings, EnableScrolling = true, HasUnevenRows = true, EnableSelection = true, Root = new TableRoot { LoginInformationSection } }; if (Device.RuntimePlatform == Device.iOS) { Table.RowHeight = -1; Table.EstimatedRowHeight = 70; } else if (Device.RuntimePlatform == Device.Android) { // NOTE: This is going to cause problems with i18n strings since various languages have difference string sizes PasswordCell.Button1.WidthRequest = 40; PasswordCell.Button2.WidthRequest = 59; UsernameCell.Button1.WidthRequest = 59; TotpCodeCell.Button1.WidthRequest = 59; UriCell.Button1.WidthRequest = 75; } Title = AppResources.ViewLogin; Content = Table; BindingContext = Model; }