Inheritance: Element, IElementSizing
Ejemplo n.º 1
0
        public IssuesController(string user, string slug)
            : base(typeof(List<IssueModel>))
        {
            User = user;
            Slug = slug;
            Style = UITableViewStyle.Plain;
            Title = "Issues";
            EnableSearch = true;
            EnableFilter = true;
            Root.UnevenRows = true;
            SearchPlaceholder = "Search Issues";

            NavigationItem.RightBarButtonItem = new UIBarButtonItem(NavigationButton.Create(CodeFramework.Images.Buttons.Add, () => {
                var b = new IssueEditController {
                    Username = User,
                    RepoSlug = Slug,
                    Success = OnCreateIssue
                };
                NavigationController.PushViewController(b, true);
            }));

            _titleView = new TitleView();
            RefreshCaption();
            NavigationItem.TitleView = _titleView;

            _loadMore = new PaginateElement("Load More", "Loading...", e => GetMore());
        }
Ejemplo n.º 2
0
        public AddEditContactScreen(UINavigationController nav)
            : base(UITableViewStyle.Grouped, null, true)
        {
            _rootContainerNavigationController = nav;

            // Navigation
            NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (sender, args) =>
            {
                NavigationController.DismissViewController(true, null);
            });
            NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, DoneButtonClicked);
            NavigationItem.Title = "New Contact";

            Root = new RootElement("");

            // Photo
            _photoSection = new Section();
            _photoBadge = new BadgeElement(UIImage.FromBundle("Images/UnknownIcon.jpg"), "Add Photo");
            _photoBadge.Tapped += PhotoBadgeTapped;
            _photoSection.Add(_photoBadge);
            Root.Add(_photoSection);

            // Name
            _nameSection = new Section();
            var firstName = new EntryElement(null, "First", null);
            var middleName = new EntryElement(null, "Middle", null);
            var lastName = new EntryElement(null, "Last", null);
            var org = new EntryElement(null, "Organization", null);
            _nameSection.Add(firstName);
            _nameSection.Add(middleName);
            _nameSection.Add(lastName);
            _nameSection.Add(org);
            Root.Add(_nameSection);

            // Phone numbers
            _phoneSection = new Section("Phone Numbers");
            Root.Add(_phoneSection);
            var phoneLoadMore = new LoadMoreElement("Add More Phone Numbers", "Loading...", PhoneLoadMoreTapped);
            _phoneSection.Add(phoneLoadMore);

            // Emails
            _emailSection = new Section("Emails");
            Root.Add(_emailSection);
            var emailLoadMore = new LoadMoreElement("Add More Emails", "Loading...", EmailLoadMoreTapped);
            _emailSection.Add(emailLoadMore);

            // Urls
            _urlSection = new Section("Urls");
            Root.Add(_urlSection);
            var urlLoadMore = new LoadMoreElement("Add More Urls", "Loading...", UrlLoadMoreTapped);
            _urlSection.Add(urlLoadMore);

            // IMs
            _instantMsgSection = new Section("Instant Messages");
            Root.Add(_instantMsgSection);
            var instantMsgLoadMore = new LoadMoreElement("Add More Instant Messages", "Loading...", InstantMsgLoadMoreTapped);
            _instantMsgSection.Add(instantMsgLoadMore);
        }
        protected override void OnRender()
        {
            //Create some needed elements
            var root = new RootElement(null) { UnevenRows = true };
            _loadMore = new PaginateElement("Load More", "Loading...", e => GetMore());
            root.Add(new Section { _loadMore });

            //Add the items that were in the update
            AddItems(root, Model as List<ChangesetModel>);

            //Update the UI
            InvokeOnMainThread(delegate {
                root.Caption = Title;
                Root = root;
            });
        }
Ejemplo n.º 4
0
        void StartLogin(DialogViewController dvc)
        {
            dvc.Root.RemoveAt (1);
            LoadMoreElement status;

            if (dvc.Root.Count == 1){
                status = new LoadMoreElement (
                Locale.GetText ("Could not authenticate with twitter"),
                Locale.GetText ("Contacting twitter"), null, UIFont.BoldSystemFontOfSize (16), UIColor.Black) {
                    Animating = true
                };
                dvc.Root.Add (new Section () { status });
            } else
                status = (LoadMoreElement) dvc.Root [1][0];

            // Spin off a thread to start the OAuth authentication process,
            // let the GUI thread show the spinner.
            ThreadPool.QueueUserWorkItem (delegate {
                var oauth = new OAuthAuthorizer (TwitterAccount.OAuthConfig);

                try {
                    if (oauth.AcquireRequestToken ()){
                        BeginInvokeOnMainThread (delegate {
                            oauth.AuthorizeUser (dvc, delegate {
                                StartupAfterAuthorization (oauth);
                            });
                        });
                        return;
                    }
                } catch (Exception e){
                    Console.WriteLine (e);
                }

                BeginInvokeOnMainThread (delegate { status.Animating = false; });
            });
        }
Ejemplo n.º 5
0
 public void UrlLoadMoreTapped(LoadMoreElement lme)
 {
     var labels = new List<string>() { "Home Page", "Home", "Work" };
     PopulateElements(lme, _urlSection, "Home Page", "Url", UIKeyboardType.Url, "Delete This Url", labels);
 }
Ejemplo n.º 6
0
        public void PopulateElements(LoadMoreElement lme, Section section, string typeLable, string valueLabel, UIKeyboardType entryKeyboardType, string deleteLabel, IList<string> labelList)
        {
            lme.Animating = false;

            var type = new StyledStringElement(typeLable) { Accessory = UITableViewCellAccessory.DetailDisclosureButton };
            section.Insert(section.Count - 1, type);
            var value = new EntryElement(null, valueLabel, null);
            value.KeyboardType = entryKeyboardType;
            section.Insert(section.Count - 1, value);

            var deleteButton = new StyledStringElement(deleteLabel)
            {
                TextColor = UIColor.Red,
            };

            deleteButton.Tapped += () =>
            {
                section.Remove(type);
                section.Remove(value);
                section.Remove(deleteButton);
            };

            // Show/Hide Delete Button
            var deleteButtonOn = false;
            type.AccessoryTapped += () =>
            {
                if (!deleteButtonOn)
                {
                    deleteButtonOn = true;
                    section.Insert(type.IndexPath.Row + 2, UITableViewRowAnimation.Bottom, deleteButton);
                }
                else
                {
                    deleteButtonOn = false;
                    section.Remove(deleteButton);
                }
            };

            type.Tapped += () =>
            {
                var labelScreen = new LabelListScreen(labelList);
                var navigation = new UINavigationController(labelScreen);
                NavigationController.PresentViewController(navigation, true, null);
            };
        }
Ejemplo n.º 7
0
 public void PhoneLoadMoreTapped(LoadMoreElement lme)
 {
     var labels = new List<string>() { "Mobile", "Home", "Work", "Main", "Home Fax", "Work Fax", "Pager", "Other" };
     PopulateElements(lme, _phoneSection, "Mobile", "Phone Number", UIKeyboardType.NumberPad, "Delete This Number", labels);
 }
Ejemplo n.º 8
0
 public void InstantMsgLoadMoreTapped(LoadMoreElement lme)
 {
     var labels = new List<string>() { "Skype", "Hangouts", "Facebook Messenger", "MSN", "Yahoo", "AIM", "QQ" };
     PopulateElements(lme, _instantMsgSection, "Skype", "IM", UIKeyboardType.ASCIICapable, "Delete This IM", labels);
 }
Ejemplo n.º 9
0
 public void EmailLoadMoreTapped(LoadMoreElement lme)
 {
     var labels = new List<string>() { "Home", "Work", "Oher" };
     PopulateElements(lme, _emailSection, "Home", "Email Address", UIKeyboardType.EmailAddress, "Delete This Email", labels);
 }
Ejemplo n.º 10
0
        void DownloadTweets(int insertPoint, long? since, long? max_id, Element removeOnInsert)
        {
            Account.ReloadTimeline (kind, since, max_id, count => {
                CancelMenu ();
                mainSection.Remove (removeOnInsert);
                if (count == -1){
                    var msg = Locale.Format ("Net failure on {0}", DateTime.Now);
                    Element insertElement;

                    if (mainSection.Count > 0 && (insertElement = mainSection [insertPoint] as StyledStringElement) != null)
                        insertElement.Caption = msg;
                    else
                        mainSection.Insert (insertPoint, new StyledStringElement (msg){
                            Font = UIFont.SystemFontOfSize (14)
                        });
                    count = 1;
                } else {
                    // If we find an overlapping value, the timeline is continous, otherwise, we offer to load more

                    // If insertPoint == 0, this is a top load, otherwise it is a "Load more tweets" load, so we
                    // need to fetch insertPoint-1 to get the actual last tweet, instead of the message.
                    long lastId = GetTableTweetId (insertPoint == 0 ? 0 : insertPoint-1) ?? 0;

                    continuous = false;
                    int nParsed;

                    Util.ReportTime ("Before Loading tweet from DB");
                    lock (Database.Main)
                        nParsed = mainSection.Insert (insertPoint, UITableViewRowAnimation.None, UnlockedFetchTweets (count, lastId, insertPoint));
                    Util.ReportTime ("Time spent loading tweets");

                    NSTimer.CreateScheduledTimer (TimeSpan.FromSeconds (0.3), delegate {
                        NavigationController.TabBarItem.BadgeValue = (nParsed > 0) ? nParsed.ToString () : null;
                    });

                    if (!continuous && nParsed > 0){
                        LoadMoreElement more = null;

                        more = new LoadMoreElement (Locale.GetText ("Load more tweets"), Locale.GetText ("Loading"), delegate {
                            more.Animating = true;
                            DownloadTweets (insertPoint + nParsed, null, GetTableTweetId (insertPoint + count-1)-1, more);
                        });
                        more.Height = 60;

                        try {
                            mainSection.Insert (insertPoint+nParsed, UITableViewRowAnimation.None, more);
                        } catch {
                            Console.WriteLine ("on {0} inserting at {1}+{2} section has {3}", kind, insertPoint, count, mainSection.Count);
                        }
                    }
                    count = nParsed;
                }
                ReloadComplete ();

                // Only scroll to last unread if this was not an intermediate "Load more tweets"
                if (insertPoint == 0 && count > 0)
                    TableView.ScrollToRow (NSIndexPath.FromRowSection (count-1, 0), UITableViewScrollPosition.Middle, false);
            });
        }
Ejemplo n.º 11
0
        void Load(int page, long since_id)
        {
            var fullUrl = BuildUrl (page, since_id);
            TwitterAccount.CurrentAccount.Download (fullUrl, false, res => {
                CancelMenu ();
                if (res == null){
                    BeginInvokeOnMainThread (delegate { Root = Util.MakeError (TimelineTitle); });
                    return;
                }
                Element [] tweetArray = (from tweet in GetTweetStream (res) select (Element) new TweetElement (tweet)).ToArray ();

                // Now on the main thread, do the UI work
                BeginInvokeOnMainThread (delegate {
                    Section section;
                    if (since_id == 0){
                        if (page == 1){
                            // If we are the first batch of data being loaded, not load more, or refresh
                            var root = new RootElement (StreamedTitle) { UnevenRows = true };
                            section = new Section ();
                            root.Add (section);
                            Root = root;
                        } else {
                            section = Root [0];
                            section.Remove (loadMore);
                        }

                        int n = section.Add (tweetArray);

                        if (n == expectedCount){
                            loadMore = new LoadMoreElement (Locale.GetText ("Load more"), Locale.GetText ("Loading"), delegate {
                                Load (page+1, 0);
                            }, UIFont.BoldSystemFontOfSize (14), UIColor.Black);
                            loadMore.Height = 60;
                            section.Add (loadMore);
                        }
                    } else {
                        section = Root [0];
                        section.Insert (0, UITableViewRowAnimation.None, tweetArray);
                    }
                    if (sinceStr != null && section.Count > 0)
                        last_id = (section [0] as TweetElement).Tweet.Id;

                    ReloadComplete ();
                });
            });
        }
        private void GetMore()
        {
            this.DoWorkNoHud(() => {
                var newChanges = OnGetData(_lastNode);

                //Always remove the first node since it should already be listed...
                if (newChanges.Count > 0)
                    newChanges.RemoveAt(0);

                //Save the last node...
                if (newChanges.Count > 0)
                {
                    AddItems(Root, newChanges);
                    _lastNode = newChanges.Last().Node;
                }

                //Should never happen. Sanity check..
                if (_loadMore != null && newChanges.Count == 0)
                {
                    InvokeOnMainThread(() => {
                        Root.Remove(_loadMore.Parent as Section);
                        _loadMore.Dispose();
                        _loadMore = null;
                    });
                }
            },
            ex => Utilities.ShowAlert("Failure to load!", "Unable to load additional enries! " + ex.Message),
            () => {
                if (_loadMore != null)
                    _loadMore.Animating = false;
            });
        }
Ejemplo n.º 13
0
 void StartGeoSearch(LoadMoreElement loading)
 {
     if (location == null){
         loading.Animating = true;
         Util.RequestLocation (newLocation => {
             loading.Animating = false;
             if (newLocation != null){
                 location = newLocation;
                 ActivateController (new SearchFromGeo (location));
             }
         });
     } else
         ActivateController (new SearchFromGeo (location));
 }