예제 #1
0
        public MoreUpdatesPage(SubscriptionInfo[] updates, bool recent) : base("MoreUpdatesPage")
        {
            Subscribe <ProfileDataResultEvent>(UpdateProfileData);

            AddTitleRow("Title");

            if (recent)
            {
                AddHeaderRow("StatusPage.RecentUpdates");
            }
            else
            {
                AddHeaderRow("StatusPage.ViewedUpdates");
            }

            foreach (var info in updates)
            {
                var row = new StatusProfileButtonRow(info.Subscriptions.Status.ServiceNode, info.AccountId, info.Profile, ProfileManager.Current.GetCachedProfileData(info.AccountId), ViewMessages, recent);
                row.UpdateMessagesCount(info);

                row.Tag = info;

                _updates.Add(row);

                AddRow(row);
            }

            AddFooterRow();

            UIApp.Run(() => QueryProfileData(updates, updates.Length));
        }
예제 #2
0
        void Update(SubscriptionInfo[] updates, StackRow addIndex, string headerName, ref HeaderRow header, List <StatusProfileButtonRow> rows, ref ButtonRow more, int max, bool recent)
        {
            var count = updates.Length;

            if (count == 0)
            {
                RemoveHeaderSection(header);
                rows.Clear();
                header = null;

                return;
            }

            if (header == null)
            {
                AddIndex = addIndex;
                AddIndex = header = AddHeaderRow(headerName);
                var footer = AddFooterRow();
                footer.Identifier = $"{headerName}Footer";
            }

            var modCount     = Math.Min(count, max);
            var requiresMore = count >= max;
            var rowCount     = rows.Count;

            if (!requiresMore && more != null)
            {
                RemoveView(more);
                more = null;
            }

            for (var i = 0; i < Math.Min(rowCount, modCount); i++)
            {
                var info = updates[i];
                var row  = rows[i];
                row.Update(info.AccountId, ProfileManager.Current.GetCachedProfileData(info.AccountId), info.Profile);
                row.UpdateMessagesCount(info);

                row.Tag = info;
            }

            AddIndexBefore = false;

            var newRows = modCount - rowCount;

            if (newRows >= 0)
            {
                if (rowCount == 0)
                {
                    AddIndex = header;
                }
                else
                {
                    AddIndex = rows[rowCount - 1];
                }

                for (var i = 0; i < newRows; i++)
                {
                    var info = updates[rowCount + i];
                    var row  = new StatusProfileButtonRow(info.Subscriptions.Status.ServiceNode, info.AccountId, info.Profile, ProfileManager.Current.GetCachedProfileData(info.AccountId), ViewMessages, recent);
                    row.UpdateMessagesCount(info);

                    row.Tag = info;

                    AddRow(row);
                    AddIndex = row;
                    rows.Add(row);
                }
            }
            else
            {
                for (var i = rowCount - 1; i >= modCount; i--)
                {
                    RemoveView(rows[i]);
                    rows.RemoveAt(i);
                }
            }

            if (requiresMore && more == null)
            {
                AddIndexBefore = false;
                AddIndex       = rows[rows.Count - 1];
                more           = AddButtonRow("More", More);
                more.RowLayout.Children.Remove(more.FontIcon);
                more.SetDetailViewIcon(Icons.AngleDoubleRight);
                more.Margin = new Thickness(20, 0, 0, 0);
            }

            if (more != null)
            {
                more.Tag = new Tuple <bool, SubscriptionInfo[]>(recent, updates);
            }
        }