Xamarin.forms - Цвет фона меняется, когда активность собирается загрузить - PullRequest
1 голос
/ 17 февраля 2020

У меня есть activity с listView, в котором есть предметы, которые ведут нас к другому занятию, которое называется Main Chat. Проблема заключается в том, что я касаюсь одного из этих предметов. Перед загрузкой соответствующего действия цвет фона основного действия меняется на зеленый. Я проверил свой код, но не могу найти ни одного примера кода, который выполняет такое поведение. Вот видео о том, что происходит, и следующий код:

Видео: https://files.fm/u/7nt2szdy# / view / 20200213_115056.mp4; воспроизведение

Пример кода "нажмите элемент"

 async void OnListItemClicked(object o, ItemTappedEventArgs e)
    {
        try
        {
            ((ListView)o).SelectedItem = null;

            var vListItem = e.Item as Classes.ClassConversation.ResultadoConversation;
            var getResposta = await Servicos.Servicos.Token(vListItem.institutionId);

            if (getResposta)
                await Navigation.PushAsync(new Chat.MainChat(vListItem, user2, true));
        }
        catch (Exception)
        {
            await DisplayAlert(Languages.AppResources.Notifications, Languages.AppResources.ErrorOccurred, "Ok");
        }
    }

Пример кода основного чата "

  public MainChat (Classes.ClassConversation.ResultadoConversation conversation, Classes.ClassUser.Result user, bool Resposta)
    {
        InitializeComponent();

        //Muda a cor do texto e o local da tab no android
        UnselectedTabColor = Color.FromHex("#80FFFFFF");
        SelectedTabColor = Color.White;

        //Muda a cor do toolbar e texto 
        if (Resposta == true)
        {
            ((NavigationPage)Xamarin.Forms.Application.Current.MainPage).BackgroundColor = (Color)App.Current.Resources["colorPrimary"];
            ((NavigationPage)Xamarin.Forms.Application.Current.MainPage).BarBackgroundColor = (Color)App.Current.Resources["colorPrimary"];
            ((NavigationPage)Xamarin.Forms.Application.Current.MainPage).BarTextColor = (Color)App.Current.Resources["white"];
        }

        if (conversation.OtherUser == null)
        {
            conversation.OtherUser = new Classes.ClassConversation.User();
            if(conversation.user_From.rowKey == user.rowKey)
            {
                conversation.OtherUser = conversation.user_To;
            }
            else
            {
                conversation.OtherUser = conversation.user_From;
            }
        }

        //Set Name and image of the other user and chat title
        if (conversation.OtherUser.photoUri != null)
            ImageUser.Source = new UriImageSource { CachingEnabled = true, Uri = conversation.OtherUser.photoUri, CacheValidity = new TimeSpan(800000, 0, 0, 0) };

        TitleChat.Text = conversation.title;
        NameOtherUser.Text = conversation.OtherUser.name;

        if(Device.RuntimePlatform != Device.iOS)
            Children.Add(new ChatPage(conversation, user));
        else
            Children.Add(new ChatPageIos(conversation, user));

        Children.Add(new Report(conversation, user));

        result = conversation;
    }
...