async Task Toggled(ExtSwitch swt) { IsBusy = true; await UIApp.Current.ChangePushChannelSubscription(this, _notificationIndex); swt.SetToogle(UIApp.Current.IsPushChannelSubscribed(_notificationIndex)); IsBusy = false; }
async Task Subscribe_Toggled(ExtSwitch swtch) { var subscribe = swtch.IsToggled; if (await ConfirmAsync(subscribe ? "ConfirmSubscribe" : "ConfirmUnsubscribe")) { IsBusy = true; UIApp.Run(() => _status.ChangeSubscription(_accountId, subscribe)); } else { swtch.SetToogle(!subscribe); } }
async Task Notification_Toggled(ExtSwitch @switch) { var notify = @switch.IsToggled; if (await ConfirmAsync(notify ? "EnableNotify" : "DisableNotify")) { IsBusy = true; if (await UIApp.Current.ChangePushChannelSubscription(this, _accountIndex)) { await MessageAsync("NotifyChanged"); } @switch.SetToogle(UIApp.Current.IsPushChannelSubscribed(_accountIndex)); IsBusy = false; } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Switch> e) { base.OnElementChanged(e); if (Control == null || Element == null) { return; } _extSwitch = (ExtSwitch)e.NewElement; if (this.Control.Checked) { this.Control.ThumbDrawable.SetColorFilter(_greyColor, PorterDuff.Mode.SrcAtop); this.Control.TrackDrawable.SetColorFilter(_greenColor, PorterDuff.Mode.Darken); } else { this.Control.ThumbDrawable.SetColorFilter(_whiteColor, PorterDuff.Mode.SrcAtop); this.Control.TrackDrawable.SetColorFilter(_greyColor, PorterDuff.Mode.Darken); } this.Control.CheckedChange += this.OnCheckedChange; }