private void Init() { SearchItem = new SearchToolBarItem(this); AddCipherItem = new AddCipherToolBarItem(this, null); ToolbarItems.Add(SearchItem); ToolbarItems.Add(AddCipherItem); ListView = new ExtendedListView(ListViewCachingStrategy.RecycleElement) { IsGroupingEnabled = true, ItemsSource = PresentationSections, HasUnevenRows = true, GroupHeaderTemplate = new DataTemplate(() => new SectionHeaderViewCell( nameof(Section<Grouping>.Name), nameof(Section<Grouping>.Count), new Thickness(16, 12))), ItemTemplate = new GroupingOrCipherDataTemplateSelector(this) }; if(Device.RuntimePlatform == Device.iOS) { ListView.RowHeight = -1; } var noDataLabel = new Label { Text = AppResources.NoItems, HorizontalTextAlignment = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"] }; var addCipherButton = new ExtendedButton { Text = AppResources.AddAnItem, Command = new Command(() => Helpers.AddCipher(this, null)), Style = (Style)Application.Current.Resources["btn-primaryAccent"] }; NoDataStackLayout = new StackLayout { Children = { noDataLabel, addCipherButton }, VerticalOptions = LayoutOptions.CenterAndExpand, Padding = new Thickness(20, 0), Spacing = 20 }; LoadingIndicator = new ActivityIndicator { IsRunning = true }; if(Device.RuntimePlatform != Device.UWP) { LoadingIndicator.VerticalOptions = LayoutOptions.CenterAndExpand; LoadingIndicator.HorizontalOptions = LayoutOptions.Center; } Content = LoadingIndicator; Title = AppResources.MyVault; }
private void Init() { var noDataLabel = new Label { Text = string.Format(AppResources.NoItemsForUri, _name ?? "--"), HorizontalTextAlignment = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"] }; var addCipherButton = new ExtendedButton { Text = AppResources.AddAnItem, Command = new Command(() => AddCipherAsync()), Style = (Style)Application.Current.Resources["btn-primaryAccent"] }; NoDataStackLayout = new StackLayout { Children = { noDataLabel, addCipherButton }, VerticalOptions = LayoutOptions.CenterAndExpand, Padding = new Thickness(20, 0), Spacing = 20 }; AddCipherItem = new AddCipherToolBarItem(this); ToolbarItems.Add(AddCipherItem); SearchItem = new SearchToolBarItem(this); ToolbarItems.Add(SearchItem); ListView = new ListView(ListViewCachingStrategy.RecycleElement) { IsGroupingEnabled = true, ItemsSource = PresentationCiphersGroup, HasUnevenRows = true, GroupHeaderTemplate = new DataTemplate(() => new SectionHeaderViewCell( nameof(Section <AutofillCipher> .Name))), ItemTemplate = new DataTemplate(() => new VaultListViewCell( (VaultListPageModel.Cipher c) => Helpers.CipherMoreClickedAsync(this, c, true))) }; if (Device.RuntimePlatform == Device.iOS) { ListView.RowHeight = -1; } Title = string.Format(AppResources.ItemsForUri, _name ?? "--"); LoadingIndicator = new ActivityIndicator { IsRunning = true, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center }; Content = LoadingIndicator; }
private void Init() { ListView = new ExtendedListView(ListViewCachingStrategy.RecycleElement) { IsGroupingEnabled = true, ItemsSource = PresentationSections, HasUnevenRows = true, GroupHeaderTemplate = new DataTemplate(() => new SectionHeaderViewCell( nameof(Section <Grouping> .Name), nameof(Section <Grouping> .Count))), GroupShortNameBinding = new Binding(nameof(Section <Grouping> .NameShort)), ItemTemplate = new GroupingOrCipherDataTemplateSelector(this) }; if (Device.RuntimePlatform == Device.iOS) { ListView.RowHeight = -1; } Search = new SearchBar { Placeholder = AppResources.Search, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Button)), CancelButtonColor = Color.FromHex("3c8dbc") }; // Bug with search bar on android 7, ref https://bugzilla.xamarin.com/show_bug.cgi?id=43975 if (Device.RuntimePlatform == Device.Android && _deviceInfoService.Version >= 24) { Search.HeightRequest = 50; } var noDataLabel = new Label { Text = _favorites ? AppResources.NoFavorites : AppResources.NoItems, HorizontalTextAlignment = TextAlignment.Center, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), Style = (Style)Application.Current.Resources["text-muted"] }; if (_folder || !string.IsNullOrWhiteSpace(_folderId)) { noDataLabel.Text = AppResources.NoItemsFolder; } else if (!string.IsNullOrWhiteSpace(_collectionId)) { noDataLabel.Text = AppResources.NoItemsCollection; } NoDataStackLayout = new StackLayout { Children = { noDataLabel }, VerticalOptions = LayoutOptions.CenterAndExpand, Padding = new Thickness(20, 0), Spacing = 20 }; if (string.IsNullOrWhiteSpace(_collectionId) && !_favorites) { NoDataStackLayout.Children.Add(new ExtendedButton { Text = AppResources.AddAnItem, Command = new Command(() => Helpers.AddCipher(this, _folderId)), Style = (Style)Application.Current.Resources["btn-primaryAccent"] }); } ResultsStackLayout = new StackLayout { Children = { Search, ListView }, Spacing = 0 }; if (!string.IsNullOrWhiteSpace(_groupingName)) { Title = _groupingName; } else if (_favorites) { Title = AppResources.Favorites; } else { Title = AppResources.SearchVault; if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.UWP) { ToolbarItems.Add(new DismissModalToolBarItem(this)); } } LoadingIndicator = new ActivityIndicator { IsRunning = true }; if (Device.RuntimePlatform != Device.UWP) { LoadingIndicator.VerticalOptions = LayoutOptions.CenterAndExpand; LoadingIndicator.HorizontalOptions = LayoutOptions.Center; } ContentView = new ContentView { Content = LoadingIndicator }; var fabLayout = new FabLayout(ContentView); if (!string.IsNullOrWhiteSpace(_uri) || _folder || !string.IsNullOrWhiteSpace(_folderId)) { if (Device.RuntimePlatform == Device.Android) { ListView.BottomPadding = 170; Fab = new Fab(fabLayout, "plus.png", (sender, args) => Helpers.AddCipher(this, _folderId)); } else { AddCipherItem = new AddCipherToolBarItem(this, _folderId); ToolbarItems.Add(AddCipherItem); } } else if (Device.RuntimePlatform == Device.Android) { ListView.BottomPadding = 50; } Content = fabLayout; }