Example #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));
        }
        async Task Update()
        {
            RemoveHeaderSection("Subscriptions");

            AddIndex = GetRow("Title");
            AddIndex = AddHeaderRow("Subscriptions");

            var count  = 0;
            var status = StatusApp.Current.GetStatus(_serviceNode.ServiceNode);

            if (status != null)
            {
                var subscrptions = status.GetSubscriptions();
                foreach (var sub in subscrptions)
                {
                    var accountId   = sub.AccountId;
                    var profileData = await ProfileManager.Current.GetProfileData(accountId, ProfileDownloadType.QueryStoredData, false);

                    var button = new StatusProfileButtonRow(status.ServiceNode, accountId, sub.Profile ?? profileData?.ProfileInfo, profileData, ViewProfile, false);
                    count++;

                    AddIndex = AddRow(button);
                }
            }

            if (count == 0)
            {
                AddIndex = AddInfoRow("NoSubscriptions");
            }

            AddFooterRow();

            UpdateSuspendedLayout();
        }
Example #3
0
        public StatusAccountPage(ProfileDataResult profileData, ServiceNode serviceNode, long accountId, StatusAccountProfileType profileType, long transactionId) : base("StatusAccountPage")
        {
            Subscribe <SubscriptionEvent>(Subscription);
            Subscribe <ProfileDataResultEvent>(ProfileData);

            StackLayout.Suspended = true;

            _transactionId = transactionId;
            _profileType   = profileType;
            _serviceNode   = serviceNode;
            _status        = StatusApp.Current.GetStatus(serviceNode);
            _accountId     = accountId;
            _accountIndex  = Chain.Index.New().Add(_accountId).Build();

            _messagesDownload = new AccountIndexTransactionDownload(accountId, StatusServiceInfo.MessageIndex, serviceNode.GetTransactionDownloadManager(StatusServiceInfo.StatusDataChainIndex))
            {
                Count = 10
            };

            AddTitleRow("Title");

            if (profileType == StatusAccountProfileType.Small || transactionId > 0)
            {
                var row = new StatusProfileButtonRow(serviceNode, _accountId, profileData?.ProfileInfo, profileData, async(button) =>
                {
                    await Navigation.PushAsync(new StatusAccountPage(profileData, serviceNode, accountId, StatusAccountProfileType.Big, transactionId));
                }, false);

                AddRow(row);
            }

            if (profileType == StatusAccountProfileType.Big && transactionId <= 0)
            {
                if (_status != null)
                {
                    AddHeaderRow("Subscription");

                    _subscribe = AddSwitchRow("Subscribe");
                    _subscribe.Switch.IsToggled    = _status.IsSubscribed(_accountId);
                    _subscribe.Switch.ToggledAsync = Subscribe_Toggled;
                    _subscribe.SetDetailViewIcon(Icons.Check);

                    _notification = AddSwitchRow("Notification");
                    _notification.Switch.IsToggled    = UIApp.Current.IsPushChannelSubscribed(_accountIndex);
                    _notification.Switch.ToggledAsync = Notification_Toggled;
                    _notification.SetDetailViewIcon(Icons.Bell);

                    AddFooterRow();
                }

                if (profileData == null || profileType == StatusAccountProfileType.Big)
                {
                    UIApp.Run(() => ProfileManager.Current.GetProfileData(_accountId, ProfileDownloadType.ForceDownload, true));
                }
            }

            IsBusy = true;
        }
Example #4
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);
            }
        }