コード例 #1
0
ファイル: SongListView.cs プロジェクト: me-next/menext-app
        // TODO: include drag and drop endpoints for a drag-n-drop controller

        // TODO: create other constructors or expose setters?

        public SongListView(SongListModel songs, SongCellFactory factory)
        {
            // use the default factory
            SetItemTemplateWithFactory(factory);

            // set the model
            this.Songs       = songs;
            this.ItemsSource = this.Songs;

            // add tap handler
            this.ItemTapped += OnItemTapped;
        }
コード例 #2
0
        public SearchView(MainController controller)
        {
            this.controller = controller;

            NavigationPage.SetHasNavigationBar(this, false);
            ISong selectedSong = null;

            resultsLabel = new Label
            {
                Text = ""
            };

            //TODO: hide playNextButton if user doesn't have permission to add to PN queue
            Button playNextButton = new Button
            {
                Text = "Add to PlayNext",
                HorizontalOptions = LayoutOptions.StartAndExpand,
            };

            playNextButton.Clicked += (sender, e) =>
            {
                if (selectedSong == null)
                {
                    return;
                }
                //TODO: add song to actual playnext queue
                Debug.WriteLine("adding song to play next: " + selectedSong.Name);
            };

            Button suggestionButton = new Button
            {
                Text = "Add to Suggestions",
                HorizontalOptions = LayoutOptions.EndAndExpand,
            };

            suggestionButton.Clicked += (sender, e) =>
            {
                if (selectedSong == null)
                {
                    return;
                }
                Debug.WriteLine("adding song to suggestions: " + selectedSong.Name);

                controller.RequestAddToSuggestions(selectedSong);
            };

            var queueButtons = new StackLayout
            {
                Padding     = 3,
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    playNextButton,
                    suggestionButton
                }
            };

            model = new SongListModel(new List <ISong>());
            SongListView songList = new SongListView(model, new BasicSongCellFactory());

            songList.OnSongSelected += (song) =>
            {
                Debug.WriteLine("selected song: " + song.Name);
                selectedSong = song;
            };

            searchBar = new SearchBar
            {
                Placeholder   = "Enter search term",
                SearchCommand = new Command(() => SearchForSong(searchBar.Text)),

                // TODO: Remove this workaround when Xamarin gets fixed
                // Without this line, the search bar is invisible in Android 7
                // See https://bugzilla.xamarin.com/show_bug.cgi?id=43975
                HeightRequest = 30
            };
            searchBar.TextChanged += (sender, e) => TextChanged(searchBar.Text);

            this.Content = new StackLayout
            {
                Padding  = LayoutConsts.DEFAULT_PADDING,
                Children =
                {
                    queueButtons,
                    searchBar,
                    resultsLabel,
                    songList,
                }
            };
        }