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

			//UI setup from code
			View.BackgroundColor = Theme.BackgroundColor;
			photoSheet = new PhotoAlertSheet();
			photoSheet.DesiredSize = photoSize;
			photoSheet.Callback = image => {
				photoViewModel.SelectedPhoto.Image = image.ToByteArray ();

				var addPhotoController = Storyboard.InstantiateViewController<AddPhotoController>();
				addPhotoController.Dismissed += (sender, e) => ReloadConfirmation ();
				PresentViewController(addPhotoController, true, null);
			};
			addPhoto.SetBackgroundImage (Theme.ButtonDark, UIControlState.Normal);
			addPhoto.SetTitleColor (UIColor.White, UIControlState.Normal);

			//Setup our toolbar
			var label = new UILabel (new RectangleF (0, 0, 120, 36)) { 
				Text = "Confirmations",
				TextColor = UIColor.White,
				BackgroundColor = UIColor.Clear,
				Font = Theme.BoldFontOfSize (16),
			};
			var descriptionButton = new UIBarButtonItem (label);
			toolbar.Items = new UIBarButtonItem[] { descriptionButton };

			photoTableView.Source = new PhotoTableSource (this);
			signatureTableView.Source = new SignatureTableSource (this);
		}
Exemple #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //UI setup from code
            View.BackgroundColor   = Theme.BackgroundColor;
            photoSheet             = new PhotoAlertSheet();
            photoSheet.DesiredSize = photoSize;
            photoSheet.Callback    = image => {
                photoViewModel.SelectedPhoto.Image = image.ToByteArray();

                var addPhotoController = Storyboard.InstantiateViewController <AddPhotoController>();
                addPhotoController.Dismissed += (sender, e) => ReloadConfirmation();
                PresentViewController(addPhotoController, true, null);
            };
            addPhoto.SetBackgroundImage(Theme.ButtonDark, UIControlState.Normal);
            addPhoto.SetTitleColor(UIColor.White, UIControlState.Normal);

            //Setup our toolbar
            var label = new UILabel(new RectangleF(0, 0, 120, 36))
            {
                Text            = "Confirmations",
                TextColor       = UIColor.White,
                BackgroundColor = UIColor.Clear,
                Font            = Theme.BoldFontOfSize(16),
            };
            var descriptionButton = new UIBarButtonItem(label);

            toolbar.Items = new UIBarButtonItem[] { descriptionButton };

            photoTableView.Source     = new PhotoTableSource(this);
            signatureTableView.Source = new SignatureTableSource(this);
        }
            public TableSource()
            {
                expenseViewModel = ServiceContainer.Resolve<ExpenseViewModel>();

                categoryCell = new UITableViewCell (UITableViewCellStyle.Default, null);
                categoryCell.TextLabel.Text = "Category";
                categoryCell.SelectionStyle = UITableViewCellSelectionStyle.None;
                categoryCell.AccessoryView = category = new UILabel (new CGRect(0f, 0f, 200f, 36f)) {
                    TextAlignment = UITextAlignment.Right,
                    BackgroundColor = UIColor.Clear,
                };

                costCell = new UITableViewCell (UITableViewCellStyle.Default, null);
                costCell.TextLabel.Text = "Cost";
                costCell.SelectionStyle = UITableViewCellSelectionStyle.None;
                costCell.AccessoryView = cost = new UITextField(new CGRect (0f, 0f, 200f, 36f))
                {
                    VerticalAlignment = UIControlContentVerticalAlignment.Center,
                    TextAlignment = UITextAlignment.Right,
                };
                cost.SetDidChangeNotification (c =>
                {
                    string text = c.Text.Replace ("$", string.Empty);
                    decimal value;
                    expenseViewModel.SelectedExpense.Cost = decimal.TryParse (text, out value) ? Math.Abs (value) : 0;
                });

                descriptionCell = new UITableViewCell (UITableViewCellStyle.Default, null) {
                    SelectionStyle = UITableViewCellSelectionStyle.None
                };
                descriptionCell.AccessoryView = description = new PlaceholderTextView (new CGRect (0f, 0f, Theme.IsiOS7 ? 515f : 470f, 90f)) {
                    BackgroundColor = UIColor.Clear,
                    Placeholder = "Please enter notes here",
                };
                description.SetDidChangeNotification (d =>
                    expenseViewModel.SelectedExpense.Description = description.Text != description.Placeholder ? d.Text : string.Empty
                );

                photoCell = new UITableViewCell(UITableViewCellStyle.Default, null) {
                    SelectionStyle = UITableViewCellSelectionStyle.None
                };

                photoButton = UIButton.FromType (UIButtonType.Custom);
                photoButton.SetBackgroundImage (Theme.AddPhoto, UIControlState.Normal);
                photoButton.SetTitle ("Add Photo", UIControlState.Normal);
                photoButton.SetTitleColor (Theme.LabelColor, UIControlState.Normal);
                photoButton.ContentEdgeInsets = new UIEdgeInsets (0f, 0f, 2f, 0f);
                photoButton.Frame = new CGRect (210f, 130f, 115f, 40f);
                photoButton.TouchUpInside += (sender, e) => {
                    if (photoSheet == null) {
                        photoSheet = new PhotoAlertSheet();

                        //Set the desired size for the resulting image
                        var size = photo.Frame.Size;
                        var scale = UIScreen.MainScreen.Scale;
                        size.Width *= scale;
                        size.Height *= scale;
                        photoSheet.DesiredSize = size;

                        //Set the callback for when the image is selected
                        photoSheet.Callback = image => {
                            if (expenseViewModel.Photo == null)
                                expenseViewModel.Photo = new ExpensePhoto { ExpenseId = expenseViewModel.SelectedExpense.Id };

                            expenseViewModel.Photo.Image = image.ToByteArray ();
                            Load (enabled);
                        };
                    }
                    photoSheet.ShowFrom (photoButton.Frame, photoCell, true);
                };
                photoCell.AddSubview (photoButton);
                var frame = photoCell.Frame;
                frame.X = 18f;
                frame.Width -= 34f;

                photo = new UIImageView (frame) {
                    AutoresizingMask = UIViewAutoresizing.All,
                    ContentMode = UIViewContentMode.ScaleAspectFit
                };

                photo.Layer.BorderWidth = 1f;
                photo.Layer.BorderColor = new CGColor (0xcf, 0xcf, 0xcf, 0x7f);
                photo.Layer.CornerRadius = 10f;
                photo.Layer.MasksToBounds = true;
                photoCell.AddSubview (photo);
            }
Exemple #4
0
            public TableSource()
            {
                expenseViewModel = ServiceContainer.Resolve <ExpenseViewModel>();

                categoryCell = new UITableViewCell(UITableViewCellStyle.Default, null);
                categoryCell.TextLabel.Text = "Category";
                categoryCell.AccessoryView  = category = new UILabel(new RectangleF(0, 0, 200, 36))
                {
                    TextAlignment   = UITextAlignment.Right,
                    BackgroundColor = UIColor.Clear,
                };
                categoryCell.SelectionStyle = UITableViewCellSelectionStyle.None;

                costCell = new UITableViewCell(UITableViewCellStyle.Default, null);
                costCell.TextLabel.Text = "Cost";
                costCell.SelectionStyle = UITableViewCellSelectionStyle.None;
                costCell.AccessoryView  = cost = new UITextField(new RectangleF(0, 0, 200, 36))
                {
                    VerticalAlignment = UIControlContentVerticalAlignment.Center,
                    TextAlignment     = UITextAlignment.Right,
                };
                cost.SetDidChangeNotification(c =>
                {
                    string text = c.Text.Replace("$", string.Empty);
                    decimal value;
                    if (decimal.TryParse(text, out value))
                    {
                        expenseViewModel.SelectedExpense.Cost = Math.Abs(value);
                    }
                    else
                    {
                        expenseViewModel.SelectedExpense.Cost = 0;
                    }
                });

                descriptionCell = new UITableViewCell(UITableViewCellStyle.Default, null);
                descriptionCell.AccessoryView = description = new PlaceholderTextView(new RectangleF(0, 0, 470, 90))
                {
                    BackgroundColor = UIColor.Clear,
                    Placeholder     = "Please enter notes here",
                };
                descriptionCell.SelectionStyle = UITableViewCellSelectionStyle.None;
                description.SetDidChangeNotification(d => {
                    if (description.Text != description.Placeholder)
                    {
                        expenseViewModel.SelectedExpense.Description = d.Text;
                    }
                    else
                    {
                        expenseViewModel.SelectedExpense.Description = string.Empty;
                    }
                });

                photoCell = new UITableViewCell(UITableViewCellStyle.Default, null);
                photoCell.SelectionStyle = UITableViewCellSelectionStyle.None;
                photoButton = UIButton.FromType(UIButtonType.Custom);
                photoButton.SetBackgroundImage(Theme.AddPhoto, UIControlState.Normal);
                photoButton.SetTitle("Add Photo", UIControlState.Normal);
                photoButton.SetTitleColor(Theme.LabelColor, UIControlState.Normal);
                photoButton.ContentEdgeInsets = new UIEdgeInsets(0, 0, 2, 0);
                photoButton.Frame             = new RectangleF(210, 130, 115, 40);
                photoButton.TouchUpInside    += (sender, e) => {
                    if (photoSheet == null)
                    {
                        photoSheet = new PhotoAlertSheet();

                        //Set the desired size for the resulting image
                        var size  = photo.Frame.Size;
                        var scale = UIScreen.MainScreen.Scale;
                        size.Width            *= scale;
                        size.Height           *= scale;
                        photoSheet.DesiredSize = size;

                        //Set the callback for when the image is selected
                        photoSheet.Callback = image => {
                            if (expenseViewModel.Photo == null)
                            {
                                expenseViewModel.Photo = new ExpensePhoto {
                                    ExpenseId = expenseViewModel.SelectedExpense.Id
                                }
                            }
                            ;
                            expenseViewModel.Photo.Image = image.ToByteArray();
                            Load(enabled);
                        };
                    }
                    photoSheet.ShowFrom(photoButton.Frame, photoCell, true);
                };
                photoCell.AddSubview(photoButton);
                var frame = photoCell.Frame;

                frame.X                   = 18;
                frame.Width              -= 34;
                photo                     = new UIImageView(frame);
                photo.AutoresizingMask    = UIViewAutoresizing.All;
                photo.ContentMode         = UIViewContentMode.ScaleAspectFit;
                photo.Layer.BorderWidth   = 1;
                photo.Layer.BorderColor   = new CGColor(0xcf, 0xcf, 0xcf, 0x7f);
                photo.Layer.CornerRadius  = 10;
                photo.Layer.MasksToBounds = true;
                photoCell.AddSubview(photo);
            }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //UI setup from code
            View.BackgroundColor   = Theme.BackgroundColor;
            photoSheet             = new PhotoAlertSheet();
            photoSheet.DesiredSize = photoSize;
            photoSheet.Callback    = image => {
                photoViewModel.SelectedPhoto.Image = image.ToByteArray();

                var addPhotoController = Storyboard.InstantiateViewController <AddPhotoController>();
                addPhotoController.Dismissed += (sender, e) => ReloadConfirmation();
                PresentViewController(addPhotoController, true, null);
            };
            addPhoto.SetBackgroundImage(Theme.ButtonDark, UIControlState.Normal);
            addPhoto.SetTitleColor(UIColor.White, UIControlState.Normal);

            //Setup our toolbar
            var label = new UILabel(new RectangleF(0, 0, 120, 36))
            {
                Text            = "Confirmations",
                TextColor       = UIColor.White,
                BackgroundColor = UIColor.Clear,
                Font            = Theme.BoldFontOfSize(16),
            };
            var descriptionButton = new UIBarButtonItem(label);

            toolbar.Items = new UIBarButtonItem[] { descriptionButton };

            photoTableView.Source     = new PhotoTableSource(this);
            signatureTableView.Source = new SignatureTableSource(this);

            if (Theme.IsiOS7)
            {
                photoTableView.RowHeight  = 64;
                addPhoto.AutoresizingMask = UIViewAutoresizing.None;
                addPhoto.SetTitleColor(Theme.LabelColor, UIControlState.Normal);
                addPhoto.SetImage(Theme.ImagePlaceholder, UIControlState.Normal);
                addPhoto.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
                addPhoto.TitleEdgeInsets     = new UIEdgeInsets(0, 18, 0, 0);

                var frame = addPhoto.Frame;
                frame.X        = 9;
                frame.Y       += 10;
                frame.Height   = 64;
                frame.Width    = addPhoto.Superview.Frame.Width - 20;
                addPhoto.Frame = frame;

                frame                    = addPhoto.Superview.Frame;
                frame.Height             = addPhoto.Frame.Bottom;
                addPhoto.Superview.Frame = frame;

                signature.TextColor           =
                    photos.TextColor          =
                        requirement.TextColor =
                            note.TextColor    = Theme.LabelColor;

                addPhoto.Font       =
                    signature.Font  =
                        photos.Font = Theme.FontOfSize(18);
                requirement.Font    =
                    note.Font       = Theme.FontOfSize(12);
            }
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			//UI setup from code
			View.BackgroundColor = Theme.BackgroundColor;
			photoSheet = new PhotoAlertSheet();
			photoSheet.DesiredSize = photoSize;
			photoSheet.Callback = image => {
				photoViewModel.SelectedPhoto.Image = image.ToByteArray ();

				var addPhotoController = Storyboard.InstantiateViewController<AddPhotoController>();
				addPhotoController.Dismissed += (sender, e) => ReloadConfirmation ();
				PresentViewController(addPhotoController, true, null);
			};
			addPhoto.SetBackgroundImage (Theme.ButtonDark, UIControlState.Normal);
			addPhoto.SetTitleColor (UIColor.White, UIControlState.Normal);

			//Setup our toolbar
			var label = new UILabel (new CGRect (0, 0, 120, 36)) {
				Text = "Confirmations",
				TextColor = UIColor.White,
				BackgroundColor = UIColor.Clear,
				Font = Theme.BoldFontOfSize (16),
			};
			var descriptionButton = new UIBarButtonItem (label);
			toolbar.Items = new UIBarButtonItem[] { descriptionButton };

			photoTableView.Source = new PhotoTableSource (this);
			signatureTableView.Source = new SignatureTableSource (this);

			if (Theme.IsiOS7) {
				photoTableView.RowHeight = 64;
				addPhoto.AutoresizingMask = UIViewAutoresizing.None;
				addPhoto.SetTitleColor (Theme.LabelColor, UIControlState.Normal);
				addPhoto.SetImage (Theme.ImagePlaceholder, UIControlState.Normal);
				addPhoto.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
				addPhoto.TitleEdgeInsets = new UIEdgeInsets (0, 18, 0, 0);

				var frame = addPhoto.Frame;
				frame.X = 9;
				frame.Y += 10;
				frame.Height = 64;
				frame.Width = addPhoto.Superview.Frame.Width - 20;
				addPhoto.Frame = frame;

				frame = addPhoto.Superview.Frame;
				frame.Height = addPhoto.Frame.Bottom;
				addPhoto.Superview.Frame = frame;

				signature.TextColor =
					photos.TextColor =
					requirement.TextColor =
					note.TextColor = Theme.LabelColor;

				addPhoto.Font =
					signature.Font =
					photos.Font = Theme.FontOfSize (18);
				requirement.Font =
					note.Font = Theme.FontOfSize (12);
			}
		}