Ejemplo n.º 1
0
        public QueueView(MainController mainController)
        {
            // TODO: clean up this testing code
            this.Title          = "Queue Placeholder";
            this.mainController = mainController;

            List <ISong> songs = new List <ISong>
            {
                //new SampleMusicService.SampleSong("A"),
                //new SampleMusicService.SampleSong("B"),
            };

            NavigationPage.SetHasNavigationBar(this, false);

            // suggestion queue model observes the pulls
            var model = new SuggestionQueueModel(songs, mainController);

            mainController.RegisterObserver(model);

            var songList = new SongListView(model, new BasicSongCellFactory());

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

            //int songCounter = 0;
            //var addButton = new Button { Text = "addSong" };
            //addButton.Clicked += (sender, e) =>
            //{
            //    var song = new SampleMusicService.SampleSong("song" + songCounter);
            //    model.Add(song);
            //    songCounter++;

            //    Debug.WriteLine("adding song: " + song.Name);
            //};

            Content = new StackLayout
            {
                Padding  = LayoutConsts.DEFAULT_PADDING,
                Children =
                {
                    //addButton,
                    new Label {
                        Text = "queue holder"
                    },
                    songList,
                }
            };
        }
Ejemplo n.º 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,
                }
            };
        }