Example #1
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            await _client.Connect();

            _input.ShouldReturn += () =>
            {
                _input.ResignFirstResponder(true);

                if (string.IsNullOrEmpty(_input.Value))
                {
                    return(true);
                }

                _client.Send(_input.Value);

                _input.Value = "";

                return(true);
            };

            _client.OnMessageReceived +=
                (sender, message) => InvokeOnMainThread(() =>
                                                        _messages.Add(new StringElement(message)));
        }
Example #2
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            var message     = new EntryElement("Message", "Type your message here", "");
            var sendMessage = new StyledStringElement("Send Message")
            {
                Alignment       = UITextAlignment.Center,
                BackgroundColor = UIColor.Green
            };
            var receivedMessages = new Section();
            var root             = new RootElement("")
            {
                new Section()
                {
                    message, sendMessage
                },
                receivedMessages
            };

            var connection = new Connection("http://localhost:8081/echo");

            sendMessage.Tapped += delegate
            {
                if (!string.IsNullOrWhiteSpace(message.Value) && connection.State == ConnectionState.Connected)
                {
                    connection.Send("iOS: " + message.Value);

                    message.Value = "";
                    message.ResignFirstResponder(true);
                }
            };

            connection.Received += data =>
            {
                InvokeOnMainThread(() =>
                                   receivedMessages.Add(new StringElement(data)));
            };


            connection.Start().ContinueWith(task =>
                                            connection.Send("iOS: Connected"));

            var viewController = new DialogViewController(root);

            window.RootViewController = viewController;

            window.MakeKeyAndVisible();

            return(true);
        }
Example #3
0
        private RootElement CreateRootElement()
        {
            var captionLabel = UIHelper.CreateLabel(
                "cross copy",
                true,
                32,
                32,
                UITextAlignment.Center,
                UIColor.Black
                );
            UILabel subcaptionLabel = UIHelper.CreateLabel(
                WELCOME_LABEL_TEXT,
                false,
                14,
                85,
                UITextAlignment.Center,
                lightTextColor
                );

            subcaptionLabel.Tag = 3;

            captionLabel.Frame    = new Rectangle(0, 10, 320, 40);
            subcaptionLabel.Frame = new Rectangle(20, 55, 280, 100);
            UIView header = new UIView(new Rectangle(0, 0, 300, 145));

            header.AddSubviews(captionLabel, subcaptionLabel);

            var root = new RootElement("Secrets")
            {
                new Section(header),
                (secretsSection = new Section("Secrets")),
                new Section()
                {
                    (secretEntry = new AdvancedEntryElement("Secret", "enter new phrase", "", null))
                }
            };

            secretsSection.AddAll(from s in AppDelegate.HistoryData.Secrets select(Element) CreateImageButtonStringElement(s));

            secretEntry.AutocapitalizationType = UITextAutocapitalizationType.None;
            secretEntry.ShouldReturn          += delegate {
                if (String.IsNullOrEmpty(secretEntry.Value))
                {
                    return(false);
                }

                var newSecret = new Secret(secretEntry.Value);
                AppDelegate.HistoryData.Secrets.Add(newSecret);

                if (root.Count == 2)
                {
                    root.Insert(1, secretsSection);
                }

                secretsSection.Insert(
                    secretsSection.Elements.Count,
                    UITableViewRowAnimation.Fade,
                    CreateImageButtonStringElement(newSecret)
                    );
                secretEntry.Value = "";
                secretEntry.ResignFirstResponder(false);
                DisplaySecretDetail(newSecret);

                return(true);
            };
            secretEntry.ReturnKeyType = UIReturnKeyType.Go;
            if (secretsSection.Count == 0)
            {
                secretEntry.BecomeFirstResponder(true);
                root.RemoveAt(1);
            }
            return(root);
        }
Example #4
0
        public SearchForm(RootElement _root, SearchRequest req = null) : base(new RootElement("Root"), true)
        {
            Root      = (_root != null) ? _root : GetRoot("root");
            searchReq = (req == null) ? new SearchRequest() : req;

            AppDelegate app = (AppDelegate)UIApplication.SharedApplication.Delegate;

            TableView.AutoresizingMask = UIViewAutoresizing.None;
            service         = app.searchService;
            yearsList       = service.GetYearList();
            maxPriceList    = service.GetMaxPricelist();
            minPriceList    = service.GetMinPricelist();
            minDistanceList = service.GetMinDistancelist();
            maxDistanceList = service.GetMaxDistancelist();
            maxPriceList    = service.GetMaxDistancelist();

            //TODO add to storage
            if (colors == null)
            {
                colors = service.GetColors();
                //colors = task.Result;
            }

            Name = new EntryElement("Name", "Create Search Name", string.Empty);
            Name.ReturnKeyType = UIReturnKeyType.Done;
            Name.ShouldReturn += () => {
                Name.ResignFirstResponder(true);
                return(true);
            };
            //Name.ShouldReturn
            Name.EntryEnded += (s, e) => {
                searchReq.name = Name.Value;
                //this.View.EndEditing(true);
            };

            Type              = GetSearchType();
            Model             = GetCarModel();
            Make              = GetCarMake();
            Zip               = new EntryElement("Zip", "Postal Code", string.Empty);
            Distance          = GetDistance();
            Trim              = GetTrim();
            Exterior          = GetExterior();
            Interior          = GetInterior();
            Seller            = GetSeller();
            SearchAuctions    = new BooleanElement("Search Auctions", true);
            SendNotifications = new BooleanElement("Send Notifications", true);

            SendNotifications.ValueChanged += (sender, e) => {
                searchReq.notify = SendNotifications.Value;
                if (this.RequestUpdated != null)
                {
                    this.RequestUpdated(this, new PostDataEvent {
                        Data = searchReq
                    });
                }
            };

            SearchAuctions.ValueChanged += (sender, e) => {
                searchReq.auctions = SearchAuctions.Value;
                if (this.RequestUpdated != null)
                {
                    this.RequestUpdated(this, new PostDataEvent {
                        Data = searchReq
                    });
                }
            };


            //header footer view for sections
            Header = GetHeader();
            Footer = GetFooter();

            View.BackgroundColor = UIColor.White;
        }
Example #5
0
        public SignInViewController() :
            base(UITableViewStyle.Grouped, new RootElement("Crisis Checkin"), false)
        {
            webService = WebServiceFactory.Create();

            username = new EntryElement("Email", "*****@*****.**", "")
            {
                KeyboardType       = UIKeyboardType.EmailAddress,
                AutocorrectionType = UITextAutocorrectionType.No
            };
            password = new EntryElement("Password", "password", "", true)
            {
                AutocorrectionType = UITextAutocorrectionType.No
            };


            Root = new RootElement("Crisis Checkin")
            {
                new Section("Already have an account?")
                {
                    username,
                    password,
                    new StyledStringElement("Sign In", async() => {
                        username.ResignFirstResponder(true);
                        password.ResignFirstResponder(true);

                        //TODO: Show progress HUD
                        ProgressHud.Show("Signing In");

                        // You have to fetch values first from MonoTouch.Dialog elements
                        username.FetchValue();
                        password.FetchValue();

                        // Actually sign in
                        var r = await webService.SignInAsync(new SignInRequest {
                            Username = username.Value,
                            Password = password.Value
                        });

                        if (!r.Succeeded)
                        {
                            // Show failure message
                            Utility.ShowError("Sign In Failed", "Invalid Username or Password");
                            return;
                        }

                        // Store our credentials for future web service calls
                        AppDelegate.Settings.SignedInUsername = username.Value;
                        AppDelegate.Settings.SignedInPassword = password.Value;

                        //TODO: Hide progress hud
                        ProgressHud.Dismiss();

                        // Navigate to commitments after successfuly login
                        commitmentsViewController = new CommitmentsViewController();
                        NavigationController.PushViewController(commitmentsViewController, true);
                    })
                    {
                        Alignment = UITextAlignment.Center
                    }
                },
                new Section("Don't have an account yet?")
                {
                    new StyledStringElement("Create an Account", () => {
                        // Navigate to registration controller
                        registerViewController = new RegisterViewController();
                        NavigationController.PushViewController(registerViewController, true);
                    })
                    {
                        Alignment = UITextAlignment.Center
                    }
                }
            };
        }