mirror of
https://github.com/bitwarden/mobile
synced 2026-01-05 18:13:36 +00:00
Site edit page. Moved site view page to a bound view model. Renamed view models to Models.Page namespace.
This commit is contained in:
52
src/App/Models/Page/VaultListPageModel.cs
Normal file
52
src/App/Models/Page/VaultListPageModel.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using Bit.App.Resources;
|
||||
|
||||
namespace Bit.App.Models.Page
|
||||
{
|
||||
public class VaultListPageModel
|
||||
{
|
||||
public class Site
|
||||
{
|
||||
public Site(Models.Site site, string folderId)
|
||||
{
|
||||
Id = site.Id;
|
||||
FolderId = folderId;
|
||||
Name = site.Name?.Decrypt();
|
||||
Username = site.Username?.Decrypt();
|
||||
Password = site.Password?.Decrypt();
|
||||
Uri = site.Uri?.Decrypt();
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string FolderId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Uri { get; set; }
|
||||
}
|
||||
|
||||
public class Folder : ObservableCollection<Site>
|
||||
{
|
||||
public Folder(IEnumerable<Models.Site> sites, string folderId = null)
|
||||
{
|
||||
foreach(var site in sites)
|
||||
{
|
||||
Items.Add(new Site(site, folderId));
|
||||
}
|
||||
}
|
||||
|
||||
public Folder(Models.Folder folder, IEnumerable<Models.Site> sites)
|
||||
: this(sites, folder.Id)
|
||||
{
|
||||
Id = folder.Id;
|
||||
Name = folder.Name?.Decrypt();
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; } = AppResources.FolderNone;
|
||||
public string FirstLetter { get { return Name.Substring(0, 1); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
93
src/App/Models/Page/VaultViewSitePageModel.cs
Normal file
93
src/App/Models/Page/VaultViewSitePageModel.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Bit.App.Resources;
|
||||
|
||||
namespace Bit.App.Models.Page
|
||||
{
|
||||
public class VaultViewSitePageModel : INotifyPropertyChanged
|
||||
{
|
||||
private string _name;
|
||||
private string _username;
|
||||
private string _password;
|
||||
private string _uri;
|
||||
private string _notes;
|
||||
private bool _showPassword;
|
||||
|
||||
public VaultViewSitePageModel() { }
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set
|
||||
{
|
||||
_name = value;
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(nameof(Name)));
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(nameof(PageTitle)));
|
||||
}
|
||||
}
|
||||
public string Username
|
||||
{
|
||||
get { return _username; }
|
||||
set
|
||||
{
|
||||
_username = value;
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(nameof(Username)));
|
||||
}
|
||||
}
|
||||
public string Password
|
||||
{
|
||||
get { return _password; }
|
||||
set
|
||||
{
|
||||
_password = value;
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(nameof(Password)));
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(nameof(MaskedPassword)));
|
||||
}
|
||||
}
|
||||
public string Uri
|
||||
{
|
||||
get { return _uri; }
|
||||
set
|
||||
{
|
||||
_uri = value;
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(nameof(Uri)));
|
||||
}
|
||||
}
|
||||
public string Notes
|
||||
{
|
||||
get { return _notes; }
|
||||
set
|
||||
{
|
||||
_notes = value;
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(nameof(Notes)));
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(nameof(ShowNotes)));
|
||||
}
|
||||
}
|
||||
public string PageTitle => Name ?? AppResources.SiteNoName;
|
||||
public bool ShowPassword
|
||||
{
|
||||
get { return _showPassword; }
|
||||
set
|
||||
{
|
||||
_showPassword = value;
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(nameof(ShowPassword)));
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(nameof(MaskedPassword)));
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(nameof(ShowHideText)));
|
||||
}
|
||||
}
|
||||
public string MaskedPassword => ShowPassword ? Password : Password == null ? null : new string('●', Password.Length);
|
||||
public string ShowHideText => ShowPassword ? AppResources.Hide : AppResources.Show;
|
||||
public bool ShowNotes => !string.IsNullOrWhiteSpace(Notes);
|
||||
|
||||
public void Update(Site site)
|
||||
{
|
||||
Name = site.Name?.Decrypt();
|
||||
Username = site.Username?.Decrypt();
|
||||
Password = site.Password?.Decrypt();
|
||||
Uri = site.Uri?.Decrypt();
|
||||
Notes = site.Notes?.Decrypt();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user