コード例 #1
0
        private async void OnToolbarItemClicked(object sender, EventArgs e)
        {
            var blocker = await _viewModel.CheckBlockUserAsync(_userId);

            var toDisplay = blocker ? AppResources.Unblock : AppResources.Block;

            var action = await DisplayActionSheet(null, AppResources.Cancel, toDisplay, AppResources.Report);

            if (action == AppResources.Report)
            {
                var targetUserId = _userId;
                await Navigation.PushAsync(new ModalObjectionableReasonsPage(targetUserId, null));
            }
            if (action == AppResources.Block)
            {
                var targetUserName = _viewModel.Profile.FirstName;
                var resultBlock    = await DisplayAlert($"{AppResources.Block} {targetUserName}?", $"{targetUserName} {AppResources.BlockUser}", AppResources.Block, AppResources.Cancel);

                if (resultBlock)
                {
                    await BlockUser(_userId);
                }
            }
            if (action == AppResources.Unblock)
            {
                await UnblockUser(_userId);
            }
            if (action == AppResources.Cancel)
            {
                return;
            }
        }