protected async override void OnAppearing() { NotesCell.Tapped += NotesCell_Tapped; EditItem.InitEvents(); var login = await _loginService.GetByIdAsync(_loginId); if (login == null) { await Navigation.PopForDeviceAsync(); return; } Model.Update(login); if (!Model.ShowUri) { LoginInformationSection.Remove(UriCell); } else if (!LoginInformationSection.Contains(UriCell)) { LoginInformationSection.Add(UriCell); } if (!Model.ShowUsername) { LoginInformationSection.Remove(UsernameCell); } else if (!LoginInformationSection.Contains(UsernameCell)) { LoginInformationSection.Add(UsernameCell); } if (!Model.ShowPassword) { LoginInformationSection.Remove(PasswordCell); } else if (!LoginInformationSection.Contains(PasswordCell)) { LoginInformationSection.Add(PasswordCell); } if (!Model.ShowNotes) { Table.Root.Remove(NotesSection); } else if (!Table.Root.Contains(NotesSection)) { Table.Root.Add(NotesSection); } base.OnAppearing(); }
protected async override void OnAppearing() { _pageDisappeared = false; NotesCell.Tapped += NotesCell_Tapped; EditItem.InitEvents(); var login = await _loginService.GetByIdAsync(_loginId); if (login == null) { await Navigation.PopForDeviceAsync(); return; } Model.Update(login); if (LoginInformationSection.Contains(UriCell)) { LoginInformationSection.Remove(UriCell); } if (Model.ShowUri) { LoginInformationSection.Add(UriCell); } if (LoginInformationSection.Contains(UsernameCell)) { LoginInformationSection.Remove(UsernameCell); } if (Model.ShowUsername) { LoginInformationSection.Add(UsernameCell); } if (LoginInformationSection.Contains(PasswordCell)) { LoginInformationSection.Remove(PasswordCell); } if (Model.ShowPassword) { LoginInformationSection.Add(PasswordCell); } if (Table.Root.Contains(NotesSection)) { Table.Root.Remove(NotesSection); } if (Model.ShowNotes) { Table.Root.Add(NotesSection); } // Totp if (LoginInformationSection.Contains(TotpCodeCell)) { LoginInformationSection.Remove(TotpCodeCell); } if (login.Totp != null && (_tokenService.TokenPremium || login.OrganizationUseTotp)) { var totpKey = login.Totp.Decrypt(login.OrganizationId); if (!string.IsNullOrWhiteSpace(totpKey)) { Model.TotpCode = Crypto.Totp(totpKey); if (!string.IsNullOrWhiteSpace(Model.TotpCode)) { TotpTick(totpKey); Device.StartTimer(new TimeSpan(0, 0, 1), () => { if (_pageDisappeared) { return(false); } TotpTick(totpKey); return(true); }); LoginInformationSection.Add(TotpCodeCell); } } } CleanupAttachmentCells(); if (Table.Root.Contains(AttachmentsSection)) { Table.Root.Remove(AttachmentsSection); } if (Model.ShowAttachments && _tokenService.TokenPremium) { AttachmentsSection = new TableSection(AppResources.Attachments); AttachmentCells = new List <AttachmentViewCell>(); foreach (var attachment in Model.Attachments.OrderBy(s => s.Name)) { var attachmentCell = new AttachmentViewCell(attachment, async() => { await OpenAttachmentAsync(login, attachment); }); AttachmentCells.Add(attachmentCell); AttachmentsSection.Add(attachmentCell); attachmentCell.InitEvents(); } Table.Root.Add(AttachmentsSection); } base.OnAppearing(); }