public override void ViewDidLoad() { base.ViewDidLoad(); BlockerView = new UIBlockerView(View, View.Frame.ToRectF( )); ResultView = new UIResultView(View, View.Frame.ToRectF( ), delegate { if (RequestingPrayers == false) { RetrievePrayerRequests( ); } }); View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor); float viewRealHeight = (float)(View.Bounds.Height - Task.NavToolbar.Frame.Height); float cardSizePerc = .83f; float cardWidth = (float)(View.Bounds.Width * cardSizePerc); float cardHeight = (float)(viewRealHeight * cardSizePerc); // setup the card positions to be to the offscreen to the left, centered on screen, and offscreen to the right float cardYOffset = (viewRealHeight * .03f); Carousel = PlatformCardCarousel.Create(View, cardWidth, cardHeight, new System.Drawing.RectangleF(0, cardYOffset, (float)View.Bounds.Width, viewRealHeight), PrivatePrayerConfig.Card_AnimationDuration); CardSize = new CGRect(0, 0, cardWidth, cardHeight); LastDownload = DateTime.MinValue; }
/// <summary> /// Animates a card from startPos to endPos over time /// </summary> protected abstract void AnimateCard(object platformObject, string animName, PointF startPos, PointF endPos, float duration, PlatformCardCarousel parentDelegate);
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { // Currently in a layout without a container, so no reason to create our view. return(null); } View view = inflater.Inflate(Resource.Layout.Prayer_Primary, container, false); view.SetOnTouchListener(this); view.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor)); ActivityIndicator = (ProgressBar)view.FindViewById <ProgressBar>(Resource.Id.prayer_primary_activityIndicator); ActivityIndicator.Visibility = ViewStates.Invisible; // create the carousel float prayerRegionHeight = GetPrayerRegionHeight( ); float cardWidth = GetCardWidth( ); float cardHeight = GetCardHeight( ); // setup the card positions to be to the offscreen to the left, centered on screen, and offscreen to the right float cardYOffset = (prayerRegionHeight - cardHeight) / 2; PrayerCardSize = new RectangleF(0, 0, cardWidth, cardHeight); // setup the card positions to be to the offscreen to the left, centered on screen, and offscreen to the right Carousel = PlatformCardCarousel.Create(view, cardWidth, cardHeight, new RectangleF(0, cardYOffset, NavbarFragment.GetCurrentContainerDisplayWidth( ), prayerRegionHeight), PrivatePrayerConfig.Card_AnimationDuration); // setup our error UI StatusLayer = view.FindViewById <View>(Resource.Id.status_background); ControlStyling.StyleBGLayer(StatusLayer); StatusText = StatusLayer.FindViewById <TextView>(Resource.Id.text); ControlStyling.StyleUILabel(StatusText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize); ResultLayer = view.FindViewById <View>(Resource.Id.result_background); ControlStyling.StyleBGLayer(ResultLayer); ResultSymbol = ResultLayer.FindViewById <TextView>(Resource.Id.resultSymbol); ResultSymbol.SetTypeface(FontManager.Instance.GetFont(PrivateControlStylingConfig.Icon_Font_Secondary), TypefaceStyle.Normal); ResultSymbol.SetTextSize(ComplexUnitType.Dip, PrivatePrayerConfig.PostPrayer_ResultSymbolSize_Droid); ResultSymbol.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_ActiveTextColor)); ResultSymbol.Text = PrivateControlStylingConfig.Result_Symbol_Failed; ResultText = ResultLayer.FindViewById <TextView>(Resource.Id.text); ControlStyling.StyleUILabel(ResultText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Large_FontSize); RetryButton = view.FindViewById <Button>(Resource.Id.retryButton); ControlStyling.StyleButton(RetryButton, GeneralStrings.Retry, ControlStylingConfig.Font_Regular, ControlStylingConfig.Large_FontSize); RetryButton.Click += (object sender, EventArgs e) => { if (IsRequesting == false) { DownloadPrayers( ); } }; return(view); }
/// <summary> /// Animates a card from startPos to endPos over time /// </summary> protected override void AnimateCard(object platformObject, string animName, PointF startPos, PointF endPos, float duration, PlatformCardCarousel parentDelegate) { // setup an animation from our current mask scale to the new one. CardValueAnimator animator = new CardValueAnimator(); animator.SetIntValues((int)startPos.X, (int)endPos.X); CarouselAnimationListener listener = new CarouselAnimationListener( ) { Parent = this }; animator.AddUpdateListener(listener); animator.AddListener(listener); animator.SetDuration(500); animator.Card = platformObject as View; animator.Start(); ActiveAnimators.Add(animator); }
/// <summary> /// Animates a card from startPos to endPos over time /// </summary> protected override void AnimateCard(object platformObject, string animName, PointF startPos, PointF endPos, float duration, PlatformCardCarousel parentDelegate) { // make sure we're not already running an animation UIView cardView = platformObject as UIView; if (cardView.Layer.AnimationForKey(animName) == null) { CABasicAnimation cardAnim = CABasicAnimation.FromKeyPath("position"); cardAnim.From = NSValue.FromPointF(startPos); cardAnim.To = NSValue.FromPointF(endPos); cardAnim.Duration = duration; cardAnim.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut); // these ensure we maintain the card position when finished cardAnim.FillMode = CAFillMode.Forwards; cardAnim.RemovedOnCompletion = false; // if a delegate was provided, give it to the card if (parentDelegate != null) { cardAnim.Delegate = new CaourselAnimDelegate() { Parent = this, Card = cardView }; } // cardView.Layer.AddAnimation(cardAnim, animName); } }