Skip to content

Commit

Permalink
iOS: Updated Equalizer views.
Browse files Browse the repository at this point in the history
Related to issue #405.
  • Loading branch information
ycastonguay committed Apr 11, 2013
1 parent adf5a61 commit a154d8a
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 71 deletions.
22 changes: 21 additions & 1 deletion MPfm/MPfm.MVP/Navigation/MobileNavigationManager.cs
Expand Up @@ -78,7 +78,7 @@ public abstract class MobileNavigationManager
public abstract void AddTab(MobileNavigationTabType type, string title, IBaseView view);
public abstract void PushTabView(MobileNavigationTabType type, IBaseView view);
public abstract void PushDialogView(string viewTitle, IBaseView view);
public abstract void PushDialogSubview(string viewTitle, IBaseView view);
public abstract void PushDialogSubview(string parentViewTitle, IBaseView view);
public abstract void PushPlayerSubview(IPlayerView playerView, IBaseView view);

public virtual void Start()
Expand Down Expand Up @@ -458,6 +458,26 @@ public virtual IEqualizerPresetsView CreateEqualizerPresetsView()
};
return _equalizerPresetsView;
}

public virtual IEqualizerPresetDetailsView CreateEqualizerPresetDetailsView()
{
// 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) =>
{
_equalizerPresetDetailsPresenter = Bootstrapper.GetContainer().Resolve<IEqualizerPresetDetailsPresenter>();
_equalizerPresetDetailsPresenter.BindView((IEqualizerPresetDetailsView)view);
};

// Create view and manage view destruction
_equalizerPresetDetailsView = Bootstrapper.GetContainer().Resolve<IEqualizerPresetDetailsView>(new NamedParameterOverloads() { { "onViewReady", onViewReady } });
_equalizerPresetDetailsView.OnViewDestroy = (view) =>
{
_equalizerPresetDetailsView = null;
_equalizerPresetDetailsPresenter = null;
};
return _equalizerPresetDetailsView;
}

}

public enum MobileNavigationTabType
Expand Down
43 changes: 25 additions & 18 deletions MPfm/MPfm.MVP/Presenters/EqualizerPresetsPresenter.cs
Expand Up @@ -15,6 +15,7 @@
// 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.Navigation;
using MPfm.MVP.Presenters.Interfaces;
using MPfm.MVP.Services.Interfaces;
using MPfm.MVP.Views;
Expand All @@ -23,46 +24,52 @@ namespace MPfm.MVP.Presenters
{
public class EqualizerPresetsPresenter : BasePresenter<IEqualizerPresetsView>, IEqualizerPresetsPresenter
{
readonly IPlayerService playerService;
readonly MobileNavigationManager _navigationManager;
readonly IPlayerService _playerService;

public EqualizerPresetsPresenter(IPlayerService playerService)
public EqualizerPresetsPresenter(MobileNavigationManager navigationManager, IPlayerService playerService)
{
// Set properties
this.playerService = playerService;
_navigationManager = navigationManager;
_playerService = playerService;
}

public void SetEQParam(int index, float value)
public override void BindView(IEqualizerPresetsView view)
{
// Set EQ and update UI
playerService.UpdateEQBand(index, value, true);
View.UpdateFader(index, value);
base.BindView(view);

view.OnBypassEqualizer = BypassEqualizer;
view.OnAddPreset = AddPreset;
view.OnLoadPreset = LoadPreset;
view.OnEditPreset = EditPreset;
view.OnDeletePreset = DeletePreset;

RefreshPresets();
}

public void BypassEQ()
private void BypassEqualizer()
{
playerService.BypassEQ();
_playerService.BypassEQ();
}

public void AutoLevel()
private void AddPreset()
{
var view = _navigationManager.CreateEqualizerPresetDetailsView();
_navigationManager.PushDialogSubview("EqualizerPresets", view);
}

public void Reset()
private void LoadPreset(string presetName)
{
playerService.ResetEQ();
for (int a = 0; a < 18; a++)
View.UpdateFader(a, 0);
}

public void LoadPreset(string presetName)
private void EditPreset(string presetName)
{
}

public void SavePreset(string presetName)
private void DeletePreset(string presetName)
{
}

public void DeletePreset(string presetName)
private void RefreshPresets()
{
}
}
Expand Down
Expand Up @@ -21,14 +21,5 @@ namespace MPfm.MVP.Presenters.Interfaces
{
public interface IEqualizerPresetsPresenter : IBasePresenter<IEqualizerPresetsView>
{
void SetEQParam(int index, float value);
void BypassEQ();
void AutoLevel();
void Reset();

void LoadPreset(string presetName);
void SavePreset(string presetName);
void DeletePreset(string presetName);
}
}

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("Update Library", view);
_navigationManager.PushDialogView("UpdateLibrary", view);
break;
}
case MobileOptionsMenuType.EqualizerPresets:
{
var view = _navigationManager.CreateEqualizerPresetsView();
_navigationManager.PushDialogView("Equalizer Presets", view);
_navigationManager.PushDialogView("EqualizerPresets", view);
break;
}
case MobileOptionsMenuType.Preferences:
Expand Down
1 change: 0 additions & 1 deletion MPfm/MPfm.MVP/Views/IEqualizerPresetDetailsView.cs
Expand Up @@ -22,6 +22,5 @@ namespace MPfm.MVP.Views
public interface IEqualizerPresetDetailsView : IBaseView
{
void UpdateFader(int index, float value);
void UpdatePresetList(IEnumerable<string> presets);
}
}
8 changes: 7 additions & 1 deletion MPfm/MPfm.MVP/Views/IEqualizerPresetsView.cs
Expand Up @@ -15,13 +15,19 @@
// 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.Collections.Generic;

namespace MPfm.MVP.Views
{
public interface IEqualizerPresetsView : IBaseView
{
void UpdateFader(int index, float value);
Action OnBypassEqualizer { get; set; }
Action OnAddPreset { get; set; }
Action<string> OnLoadPreset { get; set; }
Action<string> OnEditPreset { get; set; }
Action<string> OnDeletePreset { get; set; }

void UpdatePresetList(IEnumerable<string> presets);
}
}
Expand Up @@ -42,48 +42,45 @@ public EqualizerPresetDetailsViewController(Action<IBaseView> onViewReady)
public override void ViewDidLoad()
{
// Add navigation controller buttons
var btnDone = new UIButton(UIButtonType.Custom);
btnDone.SetTitle("Done", UIControlState.Normal);
btnDone.Layer.CornerRadius = 8;
btnDone.Layer.BackgroundColor = GlobalTheme.SecondaryColor.CGColor;
btnDone.Font = UIFont.FromName("HelveticaNeue-Bold", 12.0f);
btnDone.Frame = new RectangleF(0, 20, 60, 30);
btnDone.TouchUpInside += (sender, e) => {
this.DismissViewController(true, null);
var btnSave = new UIButton(UIButtonType.Custom);
btnSave.SetTitle("Save", UIControlState.Normal);
btnSave.Layer.CornerRadius = 8;
btnSave.Layer.BackgroundColor = GlobalTheme.SecondaryColor.CGColor;
btnSave.Font = UIFont.FromName("HelveticaNeue-Bold", 12.0f);
btnSave.Frame = new RectangleF(0, 20, 60, 30);
btnSave.TouchUpInside += (sender, e) => {
//this.DismissViewController(true, null);
NavigationController.PopViewControllerAnimated(true);
};
_btnDone = new UIBarButtonItem(btnDone);
_btnDone = new UIBarButtonItem(btnSave);

var btnAdd = new UIButton(UIButtonType.Custom);
btnAdd.SetTitle("+", UIControlState.Normal);
btnAdd.Layer.CornerRadius = 8;
btnAdd.Layer.BackgroundColor = GlobalTheme.SecondaryColor.CGColor;
btnAdd.Font = UIFont.FromName("HelveticaNeue-Bold", 18.0f);
btnAdd.Frame = new RectangleF(0, 12, 60, 30);
btnAdd.TouchUpInside += (sender, e) => {
this.DismissViewController(true, null);
};
_btnAdd = new UIBarButtonItem(btnAdd);
// var btnAdd = new UIButton(UIButtonType.Custom);
// btnAdd.SetTitle("+", UIControlState.Normal);
// btnAdd.Layer.CornerRadius = 8;
// btnAdd.Layer.BackgroundColor = GlobalTheme.SecondaryColor.CGColor;
// btnAdd.Font = UIFont.FromName("HelveticaNeue-Bold", 18.0f);
// btnAdd.Frame = new RectangleF(0, 12, 60, 30);
// btnAdd.TouchUpInside += (sender, e) => {
// this.DismissViewController(true, null);
// };
// _btnAdd = new UIBarButtonItem(btnAdd);

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

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

base.ViewDidLoad();
}

#region IEffectsView implementation
#region IEqualizerPresetDetailsView implementation

public void UpdateFader(int index, float value)
{
}

public void UpdatePresetList(System.Collections.Generic.IEnumerable<string> presets)
{
}

#endregion
}
}
Expand Up @@ -60,7 +60,7 @@ public override void ViewDidLoad()
btnAdd.Font = UIFont.FromName("HelveticaNeue-Bold", 18.0f);
btnAdd.Frame = new RectangleF(0, 12, 60, 30);
btnAdd.TouchUpInside += (sender, e) => {
this.DismissViewController(true, null);
OnAddPreset();
};
_btnAdd = new UIBarButtonItem(btnAdd);

Expand All @@ -69,16 +69,18 @@ public override void ViewDidLoad()

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

base.ViewDidLoad();
}

#region IEffectsView implementation
#region IEqualizerPresetsView implementation

public void UpdateFader(int index, float value)
{
}
public Action OnBypassEqualizer { get; set; }
public Action OnAddPreset { get; set; }
public Action<string> OnLoadPreset { get; set; }
public Action<string> OnEditPreset { get; set; }
public Action<string> OnDeletePreset { get; set; }

public void UpdatePresetList(System.Collections.Generic.IEnumerable<string> presets)
{
Expand Down
2 changes: 1 addition & 1 deletion MPfm/MPfm.iOS/Classes/Controllers/MoreViewController.cs
Expand Up @@ -74,7 +74,7 @@ public UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
cell.TextLabel.Text = _items[indexPath.Row].Value;

// Set font
cell.TextLabel.Font = UIFont.FromName("HelveticaNeue-Bold", 14);
cell.TextLabel.Font = UIFont.FromName("HelveticaNeue-Medium", 14);

// Set chevron
cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
Expand Down
4 changes: 2 additions & 2 deletions MPfm/MPfm.iOS/Classes/Delegates/AppDelegate.cs
Expand Up @@ -207,10 +207,10 @@ public void PushDialogView(string viewTitle, UIViewController viewController)
// TODO: Remove navCtrl from list when dialog is closed.
}

public void PushDialogSubview(string viewTitle, UIViewController viewController)
public void PushDialogSubview(string parentViewTitle, UIViewController viewController)
{
InvokeOnMainThread(() => {
var navCtrl = _dialogNavigationControllers.FirstOrDefault(x => x.Key == viewTitle).Value;
var navCtrl = _dialogNavigationControllers.FirstOrDefault(x => x.Key == parentViewTitle).Value;
navCtrl.PushViewController(viewController, true);
});
}
Expand Down
4 changes: 2 additions & 2 deletions MPfm/MPfm.iOS/Classes/Navigation/iOSNavigationManager.cs
Expand Up @@ -80,9 +80,9 @@ public override void PushDialogView(string viewTitle, IBaseView view)
AppDelegate.PushDialogView(viewTitle, (UIViewController)view);
}

public override void PushDialogSubview(string viewTitle, IBaseView view)
public override void PushDialogSubview(string parentViewTitle, IBaseView view)
{
AppDelegate.PushDialogSubview(viewTitle, (UIViewController)view);
AppDelegate.PushDialogSubview(parentViewTitle, (UIViewController)view);
}

public override void PushPlayerSubview(IPlayerView playerView, IBaseView view)
Expand Down
4 changes: 2 additions & 2 deletions MPfm/MPfm.iOS/Info.plist
Expand Up @@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>MP4M</string>
<key>CFBundleIconFiles</key>
<array>
<string>Images/icon57.png</string>
Expand Down Expand Up @@ -51,5 +49,7 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleDisplayName</key>
<string>MPfm</string>
</dict>
</plist>

0 comments on commit a154d8a

Please sign in to comment.