Example #1
0
        public static async Task <MenuFlyout> ShowMenu(Type type, string id, string parentId)
        {
            MenuFlyout flyout = new MenuFlyout();

            // Handle flyout type
            switch (type)
            {
            // Guild
            case Type.Guild:
                if (id != "@me")
                {
                    flyout = FlyoutCreator.MakeGuildMenu(LocalState.Guilds[id]);
                }
                break;

            // DM Channel
            case Type.DMChn:
                flyout = FlyoutCreator.MakeDMChannelMenu(LocalState.DMs[id]);
                break;

            // Group Channel
            case Type.GroupChn:
                flyout = FlyoutCreator.MakeGroupChannelMenu(LocalState.DMs[id]);
                break;

            // Category
            case Type.Category:
                if (parentId != null)
                {
                    flyout = FlyoutCreator.MakeCategoryMenu(LocalState.Guilds[parentId].channels[id].raw, parentId);
                }
                break;

            // Text Channel
            case Type.TextChn:
                if (parentId != null)
                {
                    flyout = FlyoutCreator.MakeTextChnMenu(LocalState.Guilds[parentId].channels[id]);
                }
                break;

            // Guild Member
            case Type.GuildMember:
                if (parentId != null)
                {
                    if (LocalState.Guilds[parentId].members.ContainsKey(id))
                    {
                        flyout = FlyoutCreator.MakeGuildMemberMenu(LocalState.Guilds[parentId].members[id]);
                    }
                }
                break;

            // Voice Member
            case Type.VoiceMember:
                if (parentId != null)
                {
                    if (LocalState.Guilds[parentId].members.ContainsKey(id))
                    {
                        flyout = FlyoutCreator.MakeVoiceMemberMenu(LocalState.Guilds[parentId].members[id]);
                    }
                    else
                    {
                        flyout = FlyoutCreator.MakeGuildMemberMenu(await RESTCalls.GetGuildMember(parentId, id));
                    }
                }
                break;
            }

            // Light dismiss for cinematic
            if (App.CinematicMode)
            {
                flyout.LightDismissOverlayMode = LightDismissOverlayMode.On;
            }

            // Style items
            foreach (var item in flyout.Items)
            {
                if (item.GetType() == typeof(MenuFlyoutItem))
                {
                    item.Style = (Style)Application.Current.Resources["MenuFlyoutItemStyle1"];
                }
            }

            // Return flyout
            return(flyout);
        }