Skip to content

Commit

Permalink
iOS: Added all controls for EqualizerPresetDetailsViewController. Add…
Browse files Browse the repository at this point in the history
…ed a toolbar, scrollbar with MPfmEqualizerFaderView, etc.

iOS: Added MPfmEqualizerFaderView, a control to be used in a scroll view to present a slider with EQ fader values.

Related to issue #405.
  • Loading branch information
ycastonguay committed Apr 19, 2013
1 parent e454ca7 commit 915c35b
Show file tree
Hide file tree
Showing 7 changed files with 468 additions and 60 deletions.
Expand Up @@ -26,13 +26,17 @@
using MPfm.iOS.Classes.Controllers.Base;
using MPfm.iOS.Classes.Controls;
using MPfm.iOS.Classes.Objects;
using System.Collections.Generic;

namespace MPfm.iOS
{
public partial class EqualizerPresetDetailsViewController : BaseViewController, IEqualizerPresetDetailsView
{
UIBarButtonItem _btnAdd;
UIBarButtonItem _btnDone;
UIBarButtonItem _btnCancel;
UIBarButtonItem _btnSave;
UIBarButtonItem _btnReset;
UIBarButtonItem _btnNormalize;
List<MPfmEqualizerFaderView> _faderViews = new List<MPfmEqualizerFaderView>();

public EqualizerPresetDetailsViewController(Action<IBaseView> onViewReady)
: base (onViewReady, UserInterfaceIdiomIsPhone ? "EqualizerPresetDetailsViewController_iPhone" : "EqualizerPresetDetailsViewController_iPad", null)
Expand All @@ -41,39 +45,91 @@ public EqualizerPresetDetailsViewController(Action<IBaseView> onViewReady)

public override void ViewDidLoad()
{
// Add navigation controller buttons
scrollView.BackgroundColor = GlobalTheme.BackgroundColor;
toolbar.BackgroundColor = GlobalTheme.MainColor;
viewOptions.BackgroundColor = GlobalTheme.BackgroundColor;
lblPresetName.TextColor = UIColor.White;
lblPresetName.Font = UIFont.FromName("HelveticaNeue", 14.0f);

// Add padding to text field (http://stackoverflow.com/questions/3727068/set-padding-for-uitextfield-with-uitextborderstylenone)
UIView paddingView = new UIView(new RectangleF(0, 0, 5, 20));
txtPresetName.LeftView = paddingView;
txtPresetName.LeftViewMode = UITextFieldViewMode.Always;

// Make sure the Done key closes the keyboard
txtPresetName.ShouldReturn = (a) => {
txtPresetName.ResignFirstResponder();
return true;
};

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(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);
_btnSave = new UIBarButtonItem(btnSave);

NavigationItem.SetLeftBarButtonItem(_btnDone, true);
//NavigationItem.SetRightBarButtonItem(_btnAdd, true);
var btnCancel = new UIButton(UIButtonType.Custom);
btnCancel.SetTitle("Cancel", UIControlState.Normal);
btnCancel.Layer.CornerRadius = 8;
btnCancel.Layer.BackgroundColor = GlobalTheme.SecondaryColor.CGColor;
btnCancel.Font = UIFont.FromName("HelveticaNeue-Bold", 12.0f);
btnCancel.Frame = new RectangleF(0, 12, 60, 30);
btnCancel.TouchUpInside += (sender, e) => {
NavigationController.PopViewControllerAnimated(true);
};
_btnCancel = new UIBarButtonItem(btnCancel);

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

var btnNormalize = new UIButton(UIButtonType.Custom);
btnNormalize.SetTitle("Normalize", UIControlState.Normal);
btnNormalize.Layer.CornerRadius = 8;
btnNormalize.Layer.BackgroundColor = GlobalTheme.SecondaryColor.CGColor;
btnNormalize.Font = UIFont.FromName("HelveticaNeue-Bold", 12.0f);
btnNormalize.Frame = new RectangleF(0, 12, 80, 30);
btnNormalize.TouchUpInside += (sender, e) => {
};
_btnNormalize = new UIBarButtonItem(btnNormalize);

NavigationItem.SetLeftBarButtonItem(_btnCancel, true);
NavigationItem.SetRightBarButtonItem(_btnSave, true);
toolbar.Items = new UIBarButtonItem[2]{ _btnNormalize, _btnReset };

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

for(int a = 0; a < 16; a++)
{
AddFaderToScrollView(a.ToString() + ".0 kHz");
}

base.ViewDidLoad();
}

private void AddFaderToScrollView(string frequency)
{
MPfmEqualizerFaderView view = new MPfmEqualizerFaderView(frequency);
view.Frame = new RectangleF(0, _faderViews.Count * 44, scrollView.Frame.Width, 44);
scrollView.AddSubview(view);
scrollView.ContentSize = new SizeF(scrollView.Frame.Width, (_faderViews.Count + 1) * 44);
_faderViews.Add(view);
}

#region IEqualizerPresetDetailsView implementation

Expand Down

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

1 change: 0 additions & 1 deletion MPfm/MPfm.iOS/Classes/Controllers/PlayerViewController.cs
Expand Up @@ -56,7 +56,6 @@ public override void DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();

// Flush all images and wave form cache
waveFormView.FlushCache();
if(imageViewAlbumArt.Image != null)
{
Expand Down
72 changes: 72 additions & 0 deletions MPfm/MPfm.iOS/Classes/Controls/MPfmEqualizerFaderView.cs
@@ -0,0 +1,72 @@
// 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.CoreGraphics;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MPfm.iOS.Classes.Objects;
using MPfm.iOS.Helpers;

namespace MPfm.iOS.Classes.Controls
{
[Register("MPfmEqualizerFaderView")]
public class MPfmEqualizerFaderView : UIView
{
public MPfmEqualizerFaderView(string frequency)
: base()
{
Initialize(frequency);
}

public MPfmEqualizerFaderView(IntPtr handle)
: base(handle)
{
Initialize("14.4 kHz");
}

private void Initialize(string frequency)
{
BackgroundColor = GlobalTheme.BackgroundColor;

var lblFrequency = new UILabel(new RectangleF(12, 4, 60, 36));
lblFrequency.BackgroundColor = UIColor.Clear;
lblFrequency.Text = frequency;
lblFrequency.TextColor = UIColor.White;
lblFrequency.Font = UIFont.FromName("HelveticaNeue", 12.0f);

var lblValue = new UILabel(new RectangleF(256, 4, 60, 36));
lblValue.BackgroundColor = UIColor.Clear;
lblValue.Text = "+6.0 dB";
lblValue.TextColor = UIColor.White;
lblValue.Font = UIFont.FromName("HelveticaNeue", 12.0f);

var slider = new UISlider(new RectangleF(62, 4, 186, 36));
slider.MinValue = -6;
slider.MaxValue = 6;
slider.Value = 0;
slider.SetThumbImage(UIImage.FromBundle("Images/Sliders/thumb"), UIControlState.Normal);
slider.SetMinTrackImage(UIImage.FromBundle("Images/Sliders/slider2").StretchableImage(8, 0), UIControlState.Normal);
slider.SetMaxTrackImage(UIImage.FromBundle("Images/Sliders/slider").StretchableImage(8, 0), UIControlState.Normal);

AddSubview(lblFrequency);
AddSubview(lblValue);
AddSubview(slider);
}
}
}
2 changes: 2 additions & 0 deletions MPfm/MPfm.iOS/Classes/Delegates/AppDelegate.cs
Expand Up @@ -59,6 +59,8 @@ public override bool FinishedLaunching(UIApplication app, NSDictionary options)

UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
UINavigationBar.Appearance.BackgroundColor = GlobalTheme.MainColor;
UIToolbar.Appearance.SetBackgroundImage(new UIImage(), UIToolbarPosition.Bottom, UIBarMetrics.Default);
UIToolbar.Appearance.BackgroundColor = GlobalTheme.MainColor;
//UITabBar.Appearance.SelectionIndicatorImage = new UIImage();

// Create window
Expand Down
1 change: 1 addition & 0 deletions MPfm/MPfm.iOS/MPfm.iOS.csproj
Expand Up @@ -197,6 +197,7 @@
<DependentUpon>EqualizerPresetDetailsViewController.cs</DependentUpon>
</Compile>
<Compile Include="Classes\Managers\Events\LoadPeakFileEventArgs.cs" />
<Compile Include="Classes\Controls\MPfmEqualizerFaderView.cs" />
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="XIB\iPhone\SplashViewController_iPhone.xib" />
Expand Down

0 comments on commit 915c35b

Please sign in to comment.