예제 #1
0
        private void Init()
        {
            if (Device.RuntimePlatform == Device.iOS)
            {
                ToolbarItems.Add(new DismissModalToolBarItem(this));
            }

            InitProps();

            var fabLayout = new FabLayout(Table);

            if (Device.RuntimePlatform == Device.Android)
            {
                Fab = new Fab(fabLayout, "pencil.png", async(sender, args) =>
                {
                    await Navigation.PushForDeviceAsync(new VaultEditCipherPage(_cipherId));
                });
            }
            else
            {
                EditItem = new EditCipherToolBarItem(this, _cipherId);
                ToolbarItems.Add(EditItem);
            }

            Content        = fabLayout;
            Title          = AppResources.ViewItem;
            BindingContext = Model;
        }
        private void Init()
        {
            ListView = new ExtendedListView
            {
                ItemsSource  = Folders,
                ItemTemplate = new DataTemplate(() => new SettingsFolderListViewCell(this))
            };

            if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.UWP)
            {
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
            }

            var fabLayout = new FabLayout(ListView);

            if (Device.RuntimePlatform == Device.Android)
            {
                Fab = new Fab(fabLayout, "plus.png", async(sender, args) =>
                {
                    await Navigation.PushForDeviceAsync(new SettingsAddFolderPage());
                });
                ListView.BottomPadding = 50;
            }
            else
            {
                AddItem = new AddFolderToolBarItem(this);
                ToolbarItems.Add(AddItem);
            }

            Title   = AppResources.Folders;
            Content = fabLayout;
        }
예제 #3
0
        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
            };

            SearchItem = new SearchToolBarItem(this);
            ToolbarItems.Add(SearchItem);

            ListView = new ExtendedListView(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
            };

            ContentView = new ContentView
            {
                Content = LoadingIndicator
            };

            var fabLayout = new FabLayout(ContentView);

            Fab = new Fab(fabLayout, "plus.png", async(sender, args) => await AddCipherAsync());
            ListView.BottomPadding = 170;

            Content = fabLayout;
        }
예제 #4
0
        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;
        }
        private void Init()
        {
            SearchItem = new SearchToolBarItem(this);
            ToolbarItems.Add(SearchItem);

            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;
            }

            ContentView = new ContentView
            {
                Content = LoadingIndicator
            };

            var fabLayout = new FabLayout(ContentView);

            if (Device.RuntimePlatform == Device.Android)
            {
                Fab = new Fab(fabLayout, "plus.png", (sender, args) => Helpers.AddCipher(this, null));
                ListView.BottomPadding = 170;
            }
            else
            {
                AddCipherItem = new AddCipherToolBarItem(this, null);
                ToolbarItems.Add(AddCipherItem);
            }

            Content = fabLayout;
            Title   = AppResources.MyVault;
        }