void SetText() { UkName.Text = Settings.MobileSettings.main_name; Color hexColor = (Color)Application.Current.Resources["MainColor"]; //IconViewTech.SetAppThemeColor(IconView.ForegroundProperty, hexColor, Color.White); //LabelTech.SetAppThemeColor(Label.TextColorProperty, hexColor, Color.White); FrameTop.SetAppThemeColor(Frame.BorderColorProperty, hexColor, Color.White); }
public CountersPage() { InitializeComponent(); Analytics.TrackEvent("Показания"); Accounts = new ObservableCollection <AccountInfo>(); Settings.mainPage = this; NavigationPage.SetHasNavigationBar(this, false); switch (Device.RuntimePlatform) { case Device.iOS: int statusBarHeight = DependencyService.Get <IStatusBar>().GetHeight(); Pancake.Padding = new Thickness(0, statusBarHeight, 0, 0); break; default: break; } hex = (Color)Application.Current.Resources["MainColor"]; var profile = new TapGestureRecognizer(); profile.Tapped += async(s, e) => { if (Navigation.NavigationStack.FirstOrDefault(x => x is ProfilePage) == null) { await Navigation.PushAsync(new ProfilePage()); } }; IconViewProfile.GestureRecognizers.Add(profile); var techSend = new TapGestureRecognizer(); techSend.Tapped += async(s, e) => { await Navigation.PushAsync(new AppPage()); }; LabelTech.GestureRecognizers.Add(techSend); var call = new TapGestureRecognizer(); call.Tapped += async(s, e) => { if (Settings.Person.Phone != null) { IPhoneCallTask phoneDialer; phoneDialer = CrossMessaging.Current.PhoneDialer; if (phoneDialer.CanMakePhoneCall && !string.IsNullOrWhiteSpace(Settings.Person.companyPhone)) { phoneDialer.MakePhoneCall( System.Text.RegularExpressions.Regex.Replace(Settings.Person.companyPhone, "[^+0-9]", "")); } } }; var pickLs = new TapGestureRecognizer(); pickLs.Tapped += async(s, e) => { Device.BeginInvokeOnMainThread(() => { Picker.Focus(); }); }; //StackLayoutLs.GestureRecognizers.Add(pickLs); SetTextAndColor(); getInfo(); SetTitle(); //countersList.BackgroundColor = Color.Transparent; baseForCounters.BackgroundColor = Color.Transparent; //if (Device.RuntimePlatform != Device.iOS) // countersList.Effects.Add(Effect.Resolve("MyEffects.ListViewHighlightEffect")); var goAddIdent = new TapGestureRecognizer(); goAddIdent.Tapped += async(s, e) => { /*await Dialog.Instance.ShowAsync<AddAccountDialogView>();*/ if (Navigation.NavigationStack.FirstOrDefault(x => x is AddIdent) == null) { await Navigation.PushAsync(new AddIdent((PaysPage)Settings.mainPage)); } }; StackLayoutAddIdent.GestureRecognizers.Add(goAddIdent); Color hexColor = (Color)Application.Current.Resources["MainColor"]; //IconViewLogin.SetAppThemeColor(IconView.ForegroundProperty, hexColor, Color.White); //IconViewTech.SetAppThemeColor(IconView.ForegroundProperty, hexColor, Color.White); //LabelTech.SetAppThemeColor(Label.TextColorProperty, hexColor, Color.White); FrameTop.SetAppThemeColor(MaterialFrame.BorderColorProperty, hexColor, Color.FromHex("#494949")); ChangeTheme = new Command(async() => { SetTitle(); }); MessagingCenter.Subscribe <Object>(this, "ChangeThemeCounter", (sender) => ChangeTheme.Execute(null)); //MessagingCenter.Subscribe<Object>(this, "UpdateCounters", (sender) => RefreshCommand.Execute(null)); MessagingCenter.Subscribe <Object>(this, "UpdateCounters", async(sender) => await RefreshCountersData()); MessagingCenter.Subscribe <Object, AccountInfo>(this, "AddIdent", async(sender, ident) => { //await Task.Delay(TimeSpan.FromMilliseconds(500)); if (ident != null) { var contain = Accounts.FirstOrDefault(x => x.Ident == ident.Ident); if (contain == null) { Device.BeginInvokeOnMainThread(() => Accounts.Add(ident)); } var all = Accounts.FirstOrDefault(x => x.Ident == AppResources.All); if (all == null) { Device.BeginInvokeOnMainThread(() => Accounts.Insert(0, new AccountInfo { Ident = AppResources.All, Selected = true })); } } Device.BeginInvokeOnMainThread(async() => { // //OnPropertyChanged("Accounts"); //var all = Accounts.FirstOrDefault(x => x.Ident == AppResources.All); //if (all == null) //{ // Accounts.Insert(0, new AccountInfo { Ident = AppResources.All, Selected = true }); //} //Accounts.Clear(); //Accounts.Add(new AccountInfo { Ident = AppResources.All, Selected = true }); //foreach (var account in Settings.Person.Accounts) //{ // Accounts.Add(account); //} //await RefreshCountersData(); }); }); MessagingCenter.Subscribe <Object, AccountInfo>(this, "RemoveIdent", async(sender, ident) => { //await Task.Delay(TimeSpan.FromMilliseconds(500)); Device.BeginInvokeOnMainThread(() => { if (SelectedAccount != null && ident != null) { if (SelectedAccount.Ident == ident.Ident) { SelectedAccount = null; } } if (ident != null) { Accounts.Remove(Accounts.First(x => x.Ident == ident.Ident)); } if (Accounts.Count == 1) { Accounts.Clear(); } }); }); Device.BeginInvokeOnMainThread(() => { var all = Accounts.FirstOrDefault(x => x.Ident == AppResources.All); if (all == null && Settings.Person.Accounts.Count > 0) { Accounts.Insert(0, new AccountInfo { Ident = AppResources.All, Selected = true }); } foreach (var account in Settings.Person.Accounts) { Accounts.Add(account); } }); Picker.ItemsSource = Accounts; }