Пример #1
0
        /// <summary>
        /// constructor; builds the page and controls.
        /// </summary>
        public EmaWikiPage(PageService pageService, IExternalBrowserService externalBrowserService)
        {
            _pageService = pageService;

            _searchBar = new SearchBar
            {
                Placeholder = "Search in wiki",
                IsVisible   = false
            };
            _searchBar.SearchButtonPressed += SearchBarOnSearchButtonPressed;

            var syncProgress = new SyncProgressContentView {
                IsVisible = false
            };

            SyncBootstrapper.ShowSyncProgressIn(syncProgress);

            //prominent: the webview.
            _webView              = new EmaWebView(externalBrowserService);
            _webView.RequestPage += (sender, args) => GoTo(args.PageName);
            _webView.RequestEdit += (sender, args) => EditCurrentPage();

            Content = new StackLayout
            {
                Children =
                {
                    _searchBar,
                    syncProgress,
                    _webView
                }
            };

            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Home",
                Icon    = "ic_menu_home.png",
                Command = new Command(() => GoTo(PageService.DefaultPage)),
                Order   = ToolbarItemOrder.Primary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Edit",
                Icon    = "ic_menu_edit.png",
                Command = new Command(EditCurrentPage),
                Order   = ToolbarItemOrder.Primary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Search",
                Icon    = "ic_menu_search.png",
                Order   = ToolbarItemOrder.Secondary,
                Command = new Command(() =>
                {
                    _searchBar.Text      = "";
                    _searchBar.IsVisible = !_searchBar.IsVisible;

                    if (_searchBar.IsVisible)
                    {
                        _searchBar.Focus();
                    }
                })
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Refresh",
                Command = new Command(Refresh),
                Order   = ToolbarItemOrder.Secondary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Icon    = "ic_menu_upload.png",
                Text    = "Synchronize",
                Command = new Command(async() => await Synchronize()),
                Order   = ToolbarItemOrder.Secondary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Preferences",
                Icon    = "ic_menu_preferences.png",
                Command = new Command(Settings),
                Order   = ToolbarItemOrder.Secondary
            });
        }
Пример #2
0
        /// <summary>
        /// constructor; builds the page and controls.
        /// </summary>
        public EmaWikiPage(PageService pageService, IExternalBrowserService externalBrowserService)
        {
            _pageService = pageService;

            _searchBar = new SearchBar
            {
                Placeholder = "Search in wiki",
                IsVisible = false
            };
            _searchBar.SearchButtonPressed += SearchBarOnSearchButtonPressed;

            var syncProgress = new SyncProgressContentView {IsVisible = false};
            SyncBootstrapper.ShowSyncProgressIn(syncProgress);

            //prominent: the webview.
            _webView = new EmaWebView(externalBrowserService);
            _webView.RequestPage += (sender, args) => GoTo(args.PageName);
            _webView.RequestEdit += (sender, args) => EditCurrentPage();

            Content = new StackLayout
            {
                Children =
                {
                    _searchBar,
                    syncProgress,
                    _webView
                }
            };

            ToolbarItems.Add(new ToolbarItem
            {
                Text = "Home",
                Icon = "ic_menu_home.png",
                Command = new Command(() => GoTo(PageService.DefaultPage)),
                Order = ToolbarItemOrder.Primary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text = "Edit",
                Icon = "ic_menu_edit.png",
                Command = new Command(EditCurrentPage),
                Order = ToolbarItemOrder.Primary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text = "Search",
                Icon = "ic_menu_search.png",
                Order = ToolbarItemOrder.Secondary,
                Command = new Command(() =>
                {
                    _searchBar.Text = "";
                    _searchBar.IsVisible = !_searchBar.IsVisible;

                    if (_searchBar.IsVisible)
                    {
                        _searchBar.Focus();
                    }
                })
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text = "Refresh",
                Command = new Command(Refresh),
                Order = ToolbarItemOrder.Secondary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Icon = "ic_menu_upload.png",
                Text = "Synchronize",
                Command = new Command(async () => await Synchronize()),
                Order = ToolbarItemOrder.Secondary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text = "Preferences",
                Icon = "ic_menu_preferences.png",
                Command = new Command(Settings),
                Order = ToolbarItemOrder.Secondary
            });
        }