Skip to content

Commit

Permalink
iOS: Navigation controller - Changed the way labels are positioned.
Browse files Browse the repository at this point in the history
iOS: Navigation controller - The Effects/Now Playing buttons are now working.
MobileNavigationManager: Added methods for showing Effects/Now Playing views.

Related to issue #405 and issue #409.
  • Loading branch information
ycastonguay committed Apr 4, 2013
1 parent 6a9f2f0 commit 28ec09b
Show file tree
Hide file tree
Showing 14 changed files with 278 additions and 271 deletions.
1 change: 1 addition & 0 deletions MPfm/MPfm.MVP/MPfm.MVP.iOS.csproj
Expand Up @@ -295,5 +295,6 @@
<Compile Include="Views\IPlayerStatusView.cs" />
<Compile Include="Presenters\Interfaces\IPlayerStatusPresenter.cs" />
<Compile Include="Presenters\PlayerStatusPresenter.cs" />
<Compile Include="Messages\MobileNavigationManagerCommandMessage&#x5;.cs" />
</ItemGroup>
</Project>
44 changes: 44 additions & 0 deletions MPfm/MPfm.MVP/Messages/MobileNavigationManagerCommandMessage.cs
@@ -0,0 +1,44 @@
// 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 MPfm.MVP.Models;
using TinyMessenger;

namespace MPfm.MVP.Messages
{
/// <summary>
/// Message to MobileNavigationManager to request a view change.
/// This message should be useful when a control wants to display a specific view without bound to a presenter
/// (ex: UINavigationController on iOS).
/// </summary>
public class MobileNavigationManagerCommandMessage : TinyMessageBase
{
public MobileNavigationManagerCommandMessageType CommandType { get; set; }

public MobileNavigationManagerCommandMessage(object sender, MobileNavigationManagerCommandMessageType commandType)
: base(sender)
{
CommandType = commandType;
}
}

public enum MobileNavigationManagerCommandMessageType
{
ShowPlayerView = 0,
ShowEffectsView = 1
}
}
22 changes: 19 additions & 3 deletions MPfm/MPfm.MVP/Navigation/MobileNavigationManager.cs
Expand Up @@ -22,6 +22,8 @@
using MPfm.MVP.Views;
using MPfm.MVP.Presenters.Interfaces;
using MPfm.MVP.Models;
using TinyMessenger;
using MPfm.MVP.Messages;

namespace MPfm.MVP.Navigation
{
Expand Down Expand Up @@ -73,7 +75,8 @@ public abstract class MobileNavigationManager
public abstract void HideSplash();
public abstract void AddTab(MobileNavigationTabType type, string title, IBaseView view);
public abstract void PushTabView(MobileNavigationTabType type, IBaseView view);
public abstract void PushDialogView(IBaseView view);
public abstract void PushDialogView(string viewTitle, IBaseView view);
public abstract void PushDialogSubview(string viewTitle, IBaseView view);
public abstract void PushPlayerSubview(IPlayerView playerView, IBaseView view);

public virtual void Start()
Expand Down Expand Up @@ -110,6 +113,19 @@ private IMobileOptionsMenuView CreateOptionsMenuView()
return _optionsMenuView;
}

protected void ShowPlayerView(MobileNavigationTabType tabType)
{
// Show player view only if it already exists
if(_playerView != null)
PushTabView(tabType, _playerView);
}

protected void ShowEffectsView()
{
var view = CreateEffectsView();
PushDialogView("Effects", view);
}

public virtual void BindOptionsMenuView(IMobileOptionsMenuView view)
{
// This is used only on Android, where the Options menu is bound to the activity.
Expand Down Expand Up @@ -370,8 +386,8 @@ public virtual IMarkerDetailsView CreateMarkerDetailsView(Guid markerId)
// The view invokes the OnViewReady action when the view is ready. This means the presenter can be created and bound to the view.
Action<IBaseView> onViewReady = (view) =>
{
var presenter = Bootstrapper.GetContainer().Resolve<IMarkerDetailsPresenter>(new NamedParameterOverloads(){{"markerId", markerId}});
presenter.BindView((IMarkerDetailsView)view);
_markerDetailsPresenter = Bootstrapper.GetContainer().Resolve<IMarkerDetailsPresenter>(new NamedParameterOverloads(){{"markerId", markerId}});
_markerDetailsPresenter.BindView((IMarkerDetailsView)view);
};

// Create view and manage view destruction
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.MVP/Presenters/LoopsPresenter.cs
Expand Up @@ -46,7 +46,7 @@ public override void BindView(ILoopsView view)
private void CreateLoopDetailsView()
{
var view = _navigationManager.CreateLoopDetailsView();
_navigationManager.PushDialogView(view);
_navigationManager.PushDialogView("Loop Details", view);
}

private void OnAddLoop()
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.MVP/Presenters/MarkersPresenter.cs
Expand Up @@ -71,7 +71,7 @@ public override void BindView(IMarkersView view)
private void CreateMarkerDetailsView(Guid markerId)
{
var view = _navigationManager.CreateMarkerDetailsView(markerId);
_navigationManager.PushDialogView(view);
_navigationManager.PushDialogView("Marker Details", view);
}

private void AddMarker(MarkerTemplateNameType markerTemplateNameType)
Expand Down
4 changes: 2 additions & 2 deletions MPfm/MPfm.MVP/Presenters/MobileOptionsMenuPresenter.cs
Expand Up @@ -70,13 +70,13 @@ private void OnItemClick(MobileOptionsMenuType menuType)
case MobileOptionsMenuType.UpdateLibrary:
{
var view = _navigationManager.CreateUpdateLibraryView();
_navigationManager.PushDialogView(view);
_navigationManager.PushDialogView("Update Library", view);
break;
}
case MobileOptionsMenuType.Effects:
{
var view = _navigationManager.CreateEffectsView();
_navigationManager.PushDialogView(view);
_navigationManager.PushDialogView("Effects", view);
break;
}
case MobileOptionsMenuType.Preferences:
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.MVP/Presenters/PlayerStatusPresenter.cs
Expand Up @@ -43,7 +43,7 @@ private void OnPlaylistIndexChanged(PlayerPlaylistIndexChangedMessage message)
//View.RefreshAudioFile(message.Data.AudioFileStarted);
}

public override void BindView(IPlayerMetadataView view)
public override void BindView(IPlayerStatusView view)
{
// Subscribe to view actions
base.BindView(view);
Expand Down
28 changes: 19 additions & 9 deletions MPfm/MPfm.iOS/Classes/Controllers/EffectsViewController.cs
Expand Up @@ -17,32 +17,42 @@

using System;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MPfm.iOS.Classes.Controllers.Base;
using MPfm.MVP.Navigation;
using MPfm.MVP.Views;
using MonoTouch.CoreAnimation;
using MonoTouch.CoreGraphics;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MPfm.iOS.Classes.Controllers.Base;
using MPfm.iOS.Classes.Controls;

namespace MPfm.iOS
{
public partial class EffectsViewController : BaseViewController, IEffectsView
{
UIBarButtonItem _btnAdd;
UIBarButtonItem _btnDone;

public EffectsViewController(Action<IBaseView> onViewReady)
: base (onViewReady, UserInterfaceIdiomIsPhone ? "EffectsViewController_iPhone" : "EffectsViewController_iPad", null)
{
}

public override void ViewDidLoad()
{
CAGradientLayer gradient = new CAGradientLayer();
gradient.Frame = this.View.Bounds;
gradient.Colors = new MonoTouch.CoreGraphics.CGColor[2] { new CGColor(0.1f, 0.1f, 0.1f, 1), new CGColor(0.4f, 0.4f, 0.4f, 1) }; //[NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UIColor whiteColor] CGColor], nil];
this.View.Layer.InsertSublayer(gradient, 0);

btnBarDone.Clicked += (sender, e) => {
// Add navigation controller buttons
_btnDone = new UIBarButtonItem(UIBarButtonSystemItem.Done);
_btnDone.Clicked += (sender, e) => {
this.DismissViewController(true, null);
};
_btnAdd = new UIBarButtonItem(UIBarButtonSystemItem.Add);

NavigationItem.SetLeftBarButtonItem(_btnDone, true);
NavigationItem.SetRightBarButtonItem(_btnAdd, true);

var navCtrl = (MPfmNavigationController)NavigationController;
navCtrl.SetBackButtonVisible(false);
navCtrl.SetTitle("Effects", "Equalizer Presets");

base.ViewDidLoad();
}
Expand Down
15 changes: 14 additions & 1 deletion MPfm/MPfm.iOS/Classes/Controllers/MarkerDetailsViewController.cs
Expand Up @@ -25,12 +25,14 @@
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MPfm.iOS.Classes.Controllers.Base;
using MPfm.iOS.Classes.Controls;

namespace MPfm.iOS
{
public partial class MarkerDetailsViewController : BaseViewController, IMarkerDetailsView
{
private Marker _marker = null;
Marker _marker = null;
UIBarButtonItem _btnDone;

public MarkerDetailsViewController(Action<IBaseView> onViewReady)
: base (onViewReady, UserInterfaceIdiomIsPhone ? "MarkerDetailsViewController_iPhone" : "MarkerDetailsViewController_iPad", null)
Expand Down Expand Up @@ -79,6 +81,17 @@ public override void ViewDidLoad()

sliderPosition.ValueChanged += HandleSliderPositionValueChanged;

// Add navigation controller buttons
_btnDone = new UIBarButtonItem(UIBarButtonSystemItem.Done);
_btnDone.Clicked += (sender, e) => {
this.DismissViewController(true, null);
};
NavigationItem.SetLeftBarButtonItem(_btnDone, true);

var navCtrl = (MPfmNavigationController)NavigationController;
navCtrl.SetBackButtonVisible(false);
navCtrl.SetTitle("Marker Details", "");

base.ViewDidLoad();
}

Expand Down
11 changes: 6 additions & 5 deletions MPfm/MPfm.iOS/Classes/Controllers/MarkersViewController.cs
Expand Up @@ -18,20 +18,21 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using MPfm.MVP.Presenters;
using MPfm.MVP.Views;
using MPfm.Player.Objects;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MPfm.iOS.Classes.Controllers.Base;
using MPfm.MVP.Views;
using MPfm.Player.Objects;
using MPfm.iOS.Classes.Controls;
using MPfm.iOS.Classes.Delegates;
using MPfm.MVP.Presenters;

namespace MPfm.iOS
{
public partial class MarkersViewController : BaseViewController, IMarkersView
{
private string _cellIdentifier = "MarkerCell";
private List<Marker> _markers;
string _cellIdentifier = "MarkerCell";
List<Marker> _markers;

public MarkersViewController(Action<IBaseView> onViewReady)
: base (onViewReady, UserInterfaceIdiomIsPhone ? "MarkersViewController_iPhone" : "MarkersViewController_iPad", null)
Expand Down

0 comments on commit 28ec09b

Please sign in to comment.