Example #1
0
        public InvoiceLineCell() : base(Key)
        {
            AutoAddSubview(Description = new UILabel {
                Text = "Description",
            }, 4
                           );

            AutoAddSubview(Price = new UILabel {
                Text = "Price", TextAlignment = UITextAlignment.Center
            }, 2);
            AutoAddSubview(Discount = new UIBorderedButton()
            {
                Title  = "0",
                Tapped = (b) => {
                    if (popup != null)
                    {
                        popup.Dispose();
                    }

                    var d = new DiscountViewController(line.Price)
                    {
                        DollarChanged = (dollar) => {
                            popup.Dismiss(true);
                            Line.Discount = dollar;
                        }
                    };

                    popup             = new UIPopoverController(d);
                    popup.DidDismiss += (object sender, EventArgs e) => {
                        line.Discount = 0;
                        d.Dispose();
                        popup.Dispose();
                        popup = null;
                    };
                    popup.PresentFromRect(Discount.Bounds, Discount, UIPopoverArrowDirection.Any, true);
                }
            }, 2);

            AutoAddSubview(TransTypeButton = new UIBorderedButton {
                Title = "S", TintColor = Color.LightBlue
            });
            TransTypeButton.TouchUpInside += (sender, e) => {
                var sheet = new SimpleActionSheet();
                var types = Database.Main.Table <TransactionType>().ToList();
                types.ForEach(x => sheet.Add(x.Description, Color.LightBlue, () => Line.TransType = x));
                sheet.ShowFrom(TransTypeButton.Bounds, TransTypeButton, true);
            };
            AddSubview(Total = new UILabel {
                Text = "Total", TextAlignment = UITextAlignment.Center
            }, 9, columnspan: 2);
        }
        public SettingsViewController() : base(UITableViewStyle.Grouped, null)
        {
            var testButton = new SimpleButton {
                Title      = "Test Connection",
                TitleColor = UIColor.Black,
                Tapped     = async(t) => {
                    View.DismissKeyboard();
                    var f = t.Frame;
                    t.Title = "Testing...";
                    t.Title = string.Format("Test Connection: {0}", await WebService.Main.Test());
                    t.Frame = f;
                }
            };

            this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => save());
            Root = new RootElement("Settings")
            {
                new Section("Server Settings")
                {
                    new EntryElement("Server", "http://10.0.1.2/api/", Settings.Shared.ServerUrl)
                    {
                        ShouldAutoCorrect = false,
                        ValueUpdated      = (v) => {
                            Settings.Shared.ServerUrl = v;
                        },
                    },
                    new EntryElement("Test Server", "http://10.0.1.2/api/", Settings.Shared.TestServerUrl)
                    {
                        ShouldAutoCorrect = false,
                        ValueUpdated      = (v) => {
                            Settings.Shared.TestServerUrl = v;
                        },
                    },
                    new UIViewElement("", testButton, false),
                },
                new Section("iPad Settings")
                {
                    new BooleanElement("Test Mode", Settings.Shared.TestMode)
                    {
                        ValueUpdated = (v) => {
                            Settings.Shared.TestMode = v;
                        }
                    },
                    new EntryElement("Register Id", "1", Settings.Shared.RegisterId.ToString())
                    {
                        ShouldAutoCorrect = false,
                        ValueUpdated      = (v) => {
                            try {
                                Settings.Shared.RegisterId = int.Parse(v);
                            } catch (Exception ex) {
                                Console.WriteLine(ex);
                                new SimpleAlertView("Invalid Register ID", "The Register ID must be a number").Show();
                            }
                        },
                    },
                },
                new Section("Payment Settings")
                {
                    (processorType = new StringElement("Credit Card Processor", Settings.Shared.CreditCardProcessor.ToString(), () => {
                        //
                        var sheet = new SimpleActionSheet();
                        Enum.GetValues(typeof(CreditCardProcessorType)).Cast <CreditCardProcessorType>().ToList().ForEach(x => sheet.Add(x.ToString(), Color.LightBlue, () => {
                            if (x == CreditCardProcessorType.Paypal)
                            {
                                //check if paypal is installed
                            }
                            processorType.Value = x.ToString();
                            Settings.Shared.CreditCardProcessor = x;
                            processorType.Reload();
                            UpdatePaymentDetails();
                        }));
                        sheet.ShowFrom(processorType.GetActiveCell().Bounds, processorType.GetActiveCell(), true);
                    })),
                },
                new Section()
                {
                    new StringElement("Version", NSBundle.MainBundle.InfoDictionary["CFBundleVersion"].ToString()),
                    new StringElement("Check for updates", () => Updater.Shared.Update()),
                }
            };
            UpdatePaymentDetails();
        }