Exemplo n.º 1
0
        public override void Build()
        {
            base.Build();
            Debug.WriteLine("AlphaMainPage.Rebuild();");

            AlphaApp Root = AlphaFactory.MakeSureApp();

            if (null == Friends || Settings.GetFriendCount() != Friends.Count())
            {
                Friends = Settings.GetFriendList().Select(i => AlphaFactory.MakeUserCircleGraph()).ToArray();
                for (var i = 0; i < Friends?.Count(); ++i)
                {
                    var Friend       = Settings.GetFriend(i);
                    var FriendCircle = Friends[i];
                    InitCircleGraph(FriendCircle, Friend);
                    FriendCircle.HorizontalOptions       = LayoutOptions.Center;
                    FriendCircle.VerticalOptions         = LayoutOptions.Center;
                    FriendCircle.IsVisibleLeftTimeBar    = false;
                    FriendCircle.IsVisibleSatelliteTexts = false;
                    FriendCircle.FontSize    *= 0.5f;
                    FriendCircle.CircleMargin = new Thickness(2.0);
                }
            }

            UpdateButton.Text = L["Update"];
            var SettingsButton = new Button
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Text    = L["Settings"],
                Command = new Command(o => Root.ShowSettingsPage()),
            };
            var ButtonFrame = new Grid()
            {
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            }
            .HorizontalJustificate
            (
                UpdateButton,
                SettingsButton
            );

            if (Width <= Height)
            {
                CircleGraph.WidthRequest  = Width;
                CircleGraph.HeightRequest = Math.Floor(Height * 0.10);
                foreach (var Friend in Friends)
                {
                    Friend.WidthRequest  = Math.Floor(Width / Math.Min(Math.Max(Friends.Count(), 2), 4));
                    Friend.HeightRequest = Friend.WidthRequest;
                }
                var StackContent = new StackLayout
                {
                    Spacing = 0.0,
                };
                StackContent.Children.Add(CircleGraph);
                BuildFriends(StackContent, StackOrientation.Horizontal);
                StackContent.Children.Add(ButtonFrame);
                Content = StackContent;
            }
            else
            {
                CircleGraph.WidthRequest  = Math.Floor(Width * 0.10);
                CircleGraph.HeightRequest = Math.Floor(Height * 0.60);
                foreach (var Friend in Friends)
                {
                    Friend.HeightRequest = Math.Floor(Height / Math.Min(Math.Max(Friends.Count(), 2), 4));
                    Friend.WidthRequest  = Friend.HeightRequest;
                }
                var StackContent = new StackLayout
                {
                    Orientation     = StackOrientation.Horizontal,
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    Spacing         = 0.0,
                };
                StackContent.Children.Add(CircleGraph);
                BuildFriends(StackContent, StackOrientation.Vertical);
                Content = new StackLayout
                {
                    Spacing = 0.0,
                    //BackgroundColor = Color.White,
                    Children =
                    {
                        StackContent,
                        ButtonFrame,
                    },
                };
            }

            //  Indicator を表示中にレイアウトを変えてしまうと簡潔かつ正常に Indicator を再表示できないようなので、問答無用でテキストを表示してしまう。
            UpdateButton.ShowText();

            ApplyCircleGraph(i => i.IsInvalidCanvas = true);
            OnUpdateLastPublicActivity(Settings.UserName, Domain.GetLastPublicActivity(Settings.UserName));

            var SettingsButtonAnimation = "DefaultButtn";

            if (SettingsButton.AnimationIsRunning(SettingsButtonAnimation))
            {
                SettingsButton.AbortAnimation(SettingsButtonAnimation);
            }
            AlphaTheme.Apply(this);

            if (string.IsNullOrWhiteSpace(CircleGraph.User))
            {
                var Theme = AlphaTheme.Get();
                SettingsButton.Animate
                (
                    SettingsButtonAnimation,
                    d =>
                {
                    var Rate = Math.Abs(Math.Sin(d));
                    SettingsButton.TextColor       = ColorEx.MergeWithRate(Theme.AccentColor, Theme.BackgroundColor, Rate);
                    SettingsButton.BackgroundColor = ColorEx.MergeWithRate(Theme.BackgroundColor, Theme.AccentColor, Rate);
                },
                    0.0,
                    1000.0,
                    16,
                    (uint)2000000,
                    Easing.Linear
                );
            }
        }