Skip to content

Commit

Permalink
iOS: Added presentation mode parameter to PushDialogView in MobileNav…
Browse files Browse the repository at this point in the history
…igationManager. Added custom button and image button for iOS 7 to add the depth effect like the custom flat button previously created. Fixed several more visual bugs for iOS 7. SelectPlaylistViewController is now partially working with the new Overlay presentation mode.

Related to issue #405.
  • Loading branch information
ycastonguay committed Oct 8, 2013
1 parent 36d657f commit e215e19
Show file tree
Hide file tree
Showing 39 changed files with 1,736 additions and 3,756 deletions.
2 changes: 1 addition & 1 deletion MPfm/MPfm.MVP/Models/LibraryBrowserEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace MPfm.MVP.Models
/// </summary>
public class LibraryBrowserEntity
{
public LibraryBrowserEntityType Type { get; set; }
public LibraryBrowserEntityType EntityType { get; set; }
public string Title { get; set; }
public string Subtitle { get; set; }
public LibraryQuery Query { get; set; }
Expand Down
16 changes: 11 additions & 5 deletions MPfm/MPfm.MVP/Navigation/MobileNavigationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public abstract class MobileNavigationManager
public abstract void AddTab(MobileNavigationTabType type, string title, MobileLibraryBrowserType browserType, LibraryQuery query, IBaseView view);
public abstract void PushTabView(MobileNavigationTabType type, IBaseView view);
public abstract void PushTabView(MobileNavigationTabType type, MobileLibraryBrowserType browserType, LibraryQuery query, IBaseView view);
public abstract void PushDialogView(string viewTitle, IBaseView sourceView, IBaseView view);
public abstract void PushDialogSubview(string parentViewTitle, IBaseView view);
public abstract void PushDialogView(MobileDialogPresentationType presentationType, string viewTitle, IBaseView sourceView, IBaseView view);
public abstract void PushDialogSubview(MobileDialogPresentationType presentationType, string parentViewTitle, IBaseView view);
public abstract void PushPlayerSubview(IPlayerView playerView, IBaseView view);
public abstract void PushPreferencesSubview(IPreferencesView preferencesView, IBaseView view);
public abstract void NotifyMobileLibraryBrowserQueryChange(MobileNavigationTabType type, MobileLibraryBrowserType browserType, LibraryQuery query);
Expand Down Expand Up @@ -598,7 +598,7 @@ protected virtual void CreateMarkerDetailsViewInternal(IBaseView sourceView, Act
_markerDetailsView = Bootstrapper.GetContainer().Resolve<IMarkerDetailsView>(new NamedParameterOverloads() { { "onViewReady", onViewReady } });

#if !ANDROID
PushDialogView("Marker Details", sourceView, _markerDetailsView);
PushDialogView(MobileDialogPresentationType.Standard, "Marker Details", sourceView, _markerDetailsView);
#endif
}

Expand Down Expand Up @@ -666,7 +666,7 @@ protected virtual void CreateEqualizerPresetsViewInternal(IBaseView sourceView,
_equalizerPresetsView = Bootstrapper.GetContainer().Resolve<IEqualizerPresetsView>(new NamedParameterOverloads() { { "onViewReady", onViewReady } });

#if !ANDROID
PushDialogView("Equalizer Presets", null, _equalizerPresetsView);
PushDialogView(MobileDialogPresentationType.Standard, "Equalizer Presets", null, _equalizerPresetsView);
#endif
}

Expand Down Expand Up @@ -694,7 +694,7 @@ protected virtual void CreateEqualizerPresetDetailsViewInternal(IBaseView source
_equalizerPresetDetailsView = Bootstrapper.GetContainer().Resolve<IEqualizerPresetDetailsView>(new NamedParameterOverloads() { { "onViewReady", onViewReady } });

#if !ANDROID
PushDialogSubview("Equalizer Presets", _equalizerPresetDetailsView);
PushDialogSubview(MobileDialogPresentationType.Standard, "Equalizer Presets", _equalizerPresetDetailsView);
#endif
}

Expand Down Expand Up @@ -903,4 +903,10 @@ public enum MobileNavigationTabType
PreferencesAudio = 6,
PreferencesLibrary = 7
}

public enum MobileDialogPresentationType
{
Standard = 0,
Overlay = 1
}
}
28 changes: 14 additions & 14 deletions MPfm/MPfm.MVP/Presenters/LibraryBrowserPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void TreeNodeSelected(LibraryBrowserEntity entity)
public void TreeNodeExpanded(LibraryBrowserEntity entity, object userData)
{
// Check node type
if (entity.Type == LibraryBrowserEntityType.Artists)
if (entity.EntityType == LibraryBrowserEntityType.Artists)
{
Tracing.Log("LibraryBrowserPresenter.TreeNodeExpanded -- Getting Artist nodes and refreshing view (RefreshLibraryBrowserNode)...");
View.RefreshLibraryBrowserNode(
Expand All @@ -123,7 +123,7 @@ public void TreeNodeExpanded(LibraryBrowserEntity entity, object userData)
userData
);
}
else if (entity.Type == LibraryBrowserEntityType.Albums)
else if (entity.EntityType == LibraryBrowserEntityType.Albums)
{
Tracing.Log("LibraryBrowserPresenter.TreeNodeExpanded -- Getting Album nodes and refreshing view (RefreshLibraryBrowserNode)...");
View.RefreshLibraryBrowserNode(
Expand All @@ -132,7 +132,7 @@ public void TreeNodeExpanded(LibraryBrowserEntity entity, object userData)
userData
);
}
else if (entity.Type == LibraryBrowserEntityType.Artist)
else if (entity.EntityType == LibraryBrowserEntityType.Artist)
{
Tracing.Log("LibraryBrowserPresenter.TreeNodeExpanded -- Getting ArtistAlbum nodes and refreshing view (RefreshLibraryBrowserNode)...");
View.RefreshLibraryBrowserNode(
Expand All @@ -152,17 +152,17 @@ public void TreeNodeExpanded(LibraryBrowserEntity entity, object userData)
public IEnumerable<LibraryBrowserEntity> TreeNodeExpandable(LibraryBrowserEntity entity)
{
// Check node type and get appropriate list
if (entity.Type == LibraryBrowserEntityType.Artists)
if (entity.EntityType == LibraryBrowserEntityType.Artists)
{
Tracing.Log("LibraryBrowserPresenter.TreeNodeExpandable -- Getting list of distinct artists...");
return GetArtistNodes(Filter);
}
else if (entity.Type == LibraryBrowserEntityType.Albums)
else if (entity.EntityType == LibraryBrowserEntityType.Albums)
{
Tracing.Log("LibraryBrowserPresenter.TreeNodeExpandable -- Getting list of distinct albums...");
return GetAlbumNodes(Filter);
}
else if (entity.Type == LibraryBrowserEntityType.Artist)
else if (entity.EntityType == LibraryBrowserEntityType.Artist)
{
Tracing.Log("LibraryBrowserPresenter.TreeNodeExpandable -- Getting list of distinct artist albums...");
return GetArtistAlbumNodes(Filter, entity.Query.ArtistName);
Expand Down Expand Up @@ -201,19 +201,19 @@ private IEnumerable<LibraryBrowserEntity> GetFirstLevelNodes()

list.Add(new LibraryBrowserEntity(){
Title = "All Songs",
Type = LibraryBrowserEntityType.AllSongs
EntityType = LibraryBrowserEntityType.AllSongs
});

list.Add(new LibraryBrowserEntity(){
Title = "Artists",
Type = LibraryBrowserEntityType.Artists,
SubItems = new List<LibraryBrowserEntity>(){ new LibraryBrowserEntity() { Type = LibraryBrowserEntityType.Dummy, Title = "dummy" }} // dummy node
EntityType = LibraryBrowserEntityType.Artists,
SubItems = new List<LibraryBrowserEntity>(){ new LibraryBrowserEntity() { EntityType = LibraryBrowserEntityType.Dummy, Title = "dummy" }} // dummy node
});

list.Add(new LibraryBrowserEntity(){
Title = "Albums",
Type = LibraryBrowserEntityType.Albums,
SubItems = new List<LibraryBrowserEntity>(){ new LibraryBrowserEntity() { Type = LibraryBrowserEntityType.Dummy, Title = "dummy" }} // dummy node
EntityType = LibraryBrowserEntityType.Albums,
SubItems = new List<LibraryBrowserEntity>(){ new LibraryBrowserEntity() { EntityType = LibraryBrowserEntityType.Dummy, Title = "dummy" }} // dummy node
});

return list;
Expand All @@ -234,12 +234,12 @@ private IEnumerable<LibraryBrowserEntity> GetArtistNodes(AudioFileFormat format)
{
list.Add(new LibraryBrowserEntity(){
Title = artist,
Type = LibraryBrowserEntityType.Artist,
EntityType = LibraryBrowserEntityType.Artist,
Query = new LibraryQuery(){
Format = format,
ArtistName = artist
},
SubItems = new List<LibraryBrowserEntity>(){ new LibraryBrowserEntity() { Type = LibraryBrowserEntityType.Dummy, Title = "dummy" }} // dummy node
SubItems = new List<LibraryBrowserEntity>(){ new LibraryBrowserEntity() { EntityType = LibraryBrowserEntityType.Dummy, Title = "dummy" }} // dummy node
});
}

Expand Down Expand Up @@ -288,7 +288,7 @@ private IEnumerable<LibraryBrowserEntity> GetArtistAlbumNodes(AudioFileFormat fo
{
list.Add(new LibraryBrowserEntity(){
Title = album,
Type = LibraryBrowserEntityType.Album,
EntityType = LibraryBrowserEntityType.Album,
Query = new LibraryQuery(){
Format = format,
ArtistName = artistName,
Expand Down
4 changes: 2 additions & 2 deletions MPfm/MPfm.MVP/Presenters/LibraryPreferencesPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private void UpdateLibrary()
try
{
var view = _mobileNavigationManager.CreateUpdateLibraryView();
_mobileNavigationManager.PushDialogView("Update Library", View, view);
_mobileNavigationManager.PushDialogView(MobileDialogPresentationType.Standard, "Update Library", View, view);
}
catch(Exception ex)
{
Expand All @@ -100,7 +100,7 @@ private void SelectFolders()
try
{
var view = _mobileNavigationManager.CreateSelectFoldersView();
_mobileNavigationManager.PushDialogView("Select Folders", View, view);
_mobileNavigationManager.PushDialogView(MobileDialogPresentationType.Standard, "Select Folders", View, view);
}
catch (Exception ex)
{
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.MVP/Presenters/LoopsPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void CreateLoopDetailsView()
{
#if IOS || ANDROID
var view = _mobileNavigationManager.CreateLoopDetailsView();
_mobileNavigationManager.PushDialogView("Loop Details", View, view);
_mobileNavigationManager.PushDialogView(MobileDialogPresentationType.Standard, "Loop Details", View, view);
#else
string a = string.Empty;
#endif
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.MVP/Presenters/MarkersPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private void AddMarker()
try
{
var view = _mobileNavigationManager.CreateAddMarkerView();
_mobileNavigationManager.PushDialogView("Add Marker", View, view);
_mobileNavigationManager.PushDialogView(MobileDialogPresentationType.Standard, "Add Marker", View, view);
}
catch (Exception ex)
{
Expand Down
20 changes: 10 additions & 10 deletions MPfm/MPfm.MVP/Presenters/MobileLibraryBrowserPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private void AddItemToPlaylist(int index)
Tracing.Log("MobileLibraryBrowserPresenter - AddItemToPlaylist - index: {0}", index);

var view = _navigationManager.CreateSelectPlaylistView(_items[index]);
_navigationManager.PushDialogView("Select Playlist", View, view);
_navigationManager.PushDialogView(MobileDialogPresentationType.Overlay, "Select Playlist", View, view);
}
catch (Exception ex)
{
Expand All @@ -191,7 +191,7 @@ private void PlayItem(int index)
try
{
Tracing.Log("MobileLibraryBrowserPresenter - PlayItem index: {0}", index);
if (_items[index].Type == LibraryBrowserEntityType.Artist)
if (_items[index].EntityType == LibraryBrowserEntityType.Artist)
{
Action<IBaseView> onViewBindedToPresenter = (theView) => _messengerHub.PublishAsync<MobileLibraryBrowserItemClickedMessage>(new MobileLibraryBrowserItemClickedMessage(this)
{
Expand All @@ -201,7 +201,7 @@ private void PlayItem(int index)

_navigationManager.CreatePlayerView(_tabType, onViewBindedToPresenter);
}
else if (_items[index].Type == LibraryBrowserEntityType.Album)
else if (_items[index].EntityType == LibraryBrowserEntityType.Album)
{
Action<IBaseView> onViewBindedToPresenter = (theView) => _messengerHub.PublishAsync<MobileLibraryBrowserItemClickedMessage>(new MobileLibraryBrowserItemClickedMessage(this)
{
Expand All @@ -211,7 +211,7 @@ private void PlayItem(int index)

_navigationManager.CreatePlayerView(_tabType, onViewBindedToPresenter);
}
else if (_items[index].Type == LibraryBrowserEntityType.Song)
else if (_items[index].EntityType == LibraryBrowserEntityType.Song)
{
Action<IBaseView> onViewBindedToPresenter = (theView) => _messengerHub.PublishAsync<MobileLibraryBrowserItemClickedMessage>(new MobileLibraryBrowserItemClickedMessage(this)
{
Expand Down Expand Up @@ -253,7 +253,7 @@ private void DeleteItem(int index)
{
Tracing.Log("MobileLibraryBrowserPresenter - DeleteItem index: {0}", index);
Task.Factory.StartNew(() => {
if(_items[index].Type == LibraryBrowserEntityType.Artist)
if(_items[index].EntityType == LibraryBrowserEntityType.Artist)
{
_libraryService.DeleteAudioFiles(_items[index].Query.ArtistName, string.Empty);
Tracing.Log("MobileLibraryBrowserPresenter - Deleting files from hard disk...");
Expand All @@ -272,12 +272,12 @@ private void DeleteItem(int index)
Tracing.Log("MobileLibraryBrowserPresenter - Removing audio files from cache...");
_audioFileCacheService.RemoveAudioFiles(_items[index].Query.ArtistName, string.Empty);
}
else if(_items[index].Type == LibraryBrowserEntityType.Album)
else if(_items[index].EntityType == LibraryBrowserEntityType.Album)
{
_libraryService.DeleteAudioFiles(_items[index].Query.ArtistName, _items[index].Query.AlbumTitle);
_audioFileCacheService.RemoveAudioFiles(_items[index].Query.ArtistName, _items[index].Query.AlbumTitle);
}
else if(_items[index].Type == LibraryBrowserEntityType.Song)
else if(_items[index].EntityType == LibraryBrowserEntityType.Song)
{
_libraryService.DeleteAudioFile(_items[index].AudioFile.Id);
_audioFileCacheService.RemoveAudioFile(_items[index].AudioFile.Id);
Expand Down Expand Up @@ -409,7 +409,7 @@ private IEnumerable<LibraryBrowserEntity> GetArtists()
list.Add(new LibraryBrowserEntity()
{
Title = artist,
Type = LibraryBrowserEntityType.Artist,
EntityType = LibraryBrowserEntityType.Artist,
AlbumTitles = albums[artist].ToList(),
Query = new LibraryQuery()
{
Expand Down Expand Up @@ -449,7 +449,7 @@ private IEnumerable<LibraryBrowserEntity> GetAlbums(string artistName)
list.Add(new LibraryBrowserEntity(){
Title = album.Value,
Subtitle = album.Key,
Type = LibraryBrowserEntityType.Album,
EntityType = LibraryBrowserEntityType.Album,
Query = new LibraryQuery(){
Format = format,
ArtistName = artistName,
Expand Down Expand Up @@ -486,7 +486,7 @@ private IEnumerable<LibraryBrowserEntity> GetSongs(string artistName, string alb
Title = audioFile.Title,
Subtitle = audioFile.Length,
AudioFile = audioFile,
Type = LibraryBrowserEntityType.Song,
EntityType = LibraryBrowserEntityType.Song,
Query = new LibraryQuery()
{
Format = format,
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.MVP/Presenters/MobileOptionsMenuPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void OnItemClick(MobileOptionsMenuType menuType)
case MobileOptionsMenuType.UpdateLibrary:
{
var view = _navigationManager.CreateUpdateLibraryView();
_navigationManager.PushDialogView("Update Library", View, view);
_navigationManager.PushDialogView(MobileDialogPresentationType.Standard, "Update Library", View, view);
break;
}
case MobileOptionsMenuType.SyncLibrary:
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.MVP/Presenters/SelectPlaylistPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void AddNewPlaylist()
try
{
var view = _mobileNavigationManager.CreateAddPlaylistView();
_mobileNavigationManager.PushDialogView("Add New Playlist", View, view);
_mobileNavigationManager.PushDialogView(MobileDialogPresentationType.Standard, "Add New Playlist", View, view);
}
catch (Exception ex)
{
Expand Down
50 changes: 50 additions & 0 deletions MPfm/MPfm.iOS/Classes/Controllers/AddPlaylistViewController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MPfm.iOS.Classes.Controllers.Base;
using MPfm.MVP.Views;

namespace MPfm.iOS
{
public partial class AddPlaylistViewController : BaseViewController, IAddPlaylistView
{
public AddPlaylistViewController(Action<IBaseView> onViewReady)
: base (onViewReady, UserInterfaceIdiomIsPhone ? "AddPlaylistViewController_iPhone" : "AddPlaylistViewController_iPad", null)
{
}

public override void ViewDidLoad()
{
base.ViewDidLoad();
}

#region IAddPlaylistView implementation

public Action<string> OnSavePlaylist { get; set; }

public void AddPlaylistError(Exception ex)
{
}

#endregion
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,15 @@ public override void ViewDidLoad()
btnSaveView.AddSubview(btnSave);
_btnSave = new UIBarButtonItem(btnSaveView);

var btnReset = new UIButton(UIButtonType.Custom);
var btnReset = new MPfmButton();
btnReset.SetTitle("Reset", UIControlState.Normal);
btnReset.Layer.CornerRadius = 8;
btnReset.Layer.BackgroundColor = GlobalTheme.SecondaryColor.CGColor;
btnReset.Font = UIFont.FromName("HelveticaNeue", 12.0f);
btnReset.Frame = new RectangleF(0, 12, 60, 30);
btnReset.TouchUpInside += HandleButtonResetTouchUpInside;
_btnReset = new UIBarButtonItem(btnReset);

var btnNormalize = new UIButton(UIButtonType.Custom);
var btnNormalize = new MPfmButton();
btnNormalize.SetTitle("Normalize", UIControlState.Normal);
btnNormalize.Layer.CornerRadius = 8;
btnNormalize.Layer.BackgroundColor = GlobalTheme.SecondaryColor.CGColor;
btnNormalize.Font = UIFont.FromName("HelveticaNeue", 12.0f);
btnNormalize.Frame = new RectangleF(0, 12, 80, 30);
btnNormalize.TouchUpInside += HandleButtonNormalizeTouchUpInside;
Expand Down
Loading

0 comments on commit e215e19

Please sign in to comment.