示例#1
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            Window = new UIWindow(UIScreen.MainScreen.Bounds);

            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method

            // Code to start the Xamarin Test Cloud Agent
#if ENABLE_TEST_CLOUD
            //Xamarin.Calabash.Start();
#endif

            ServiceLocator.Instance.Add <IS3Service, S3Service>();
            ServiceLocator.Instance.Add <IImageDownloader, ImageDownloader>();
            ServiceLocator.Instance.Add <IPersistantStorage, PersistantStorage>();
            ServiceLocator.Instance.Add <IBroadcastNotificaion, BroadCastNotificaion>();

            Profile.EnableUpdatesOnAccessTokenChange(true);
            Settings.AppID       = NotSensitive.SlinkKeys.facebook_app_id;
            Settings.DisplayName = NotSensitive.SlinkKeys.facebook_display_name;

            if (RealmUserServices.DidUserPersist())
            {
                ApplicationExtensions.EnterApplication(false, true);
            }
            else
            {
                ApplicationExtensions.LoadStoryboardRoot("Landing", false);
            }

            SetupUnauthorizedCatcher();
            PredownloadImages();

            AppCenter.Start("fa06eb43-8be9-426c-97f9-42f3ab13cd3b", typeof(Analytics), typeof(Crashes));
            ServiceRunner.SharedInstance.StartService <AppCenterManager>();

            MobileAds.Configure("ca-app-pub-4252799872870196~2848379026");
            return(true);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();


            //if user has no cards, create their facebook one
            var me = RealmUserServices.GetMe(false);

            if (me.Cards.Count() == 0)
            {
                var outlet = me.Outlets.Where(c => c.Type.Equals(Outlet.outlet_type_facebook, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
                if (outlet != null)
                {
                    var card = Card.Create();
                    card.AddOutlet(outlet);

                    var realm = RealmManager.SharedInstance.GetRealm(null);
                    realm.Write(() =>
                    {
                        card.Name  = "Facebook Card";
                        card.Owner = me;
                    });
                }
            }


            NavigationItem.RightBarButtonItem = new UIBarButtonItem(Strings.Basic.skip, UIBarButtonItemStyle.Plain, (sender, e) =>
            {
                Cancelled = true;

                removeAllSubviews(false, () =>
                {
                    //ApplicationExtensions.LoadStoryboardRoot("Landing", false);
                    ApplicationExtensions.EnterApplication(false, true);
                });
            });
        }
        void StartPartFour(Action completed)
        {
            if (Cancelled)
            {
                return;
            }

            var get_notified_label = GetDefaultLabel(Strings.Onboarding.get_notified);

            get_notified_label.Frame = new CGRect(100, 50, 200, 70);
            get_notified_label.Alpha = 0;
            View.AddSubview(get_notified_label);

            var redDot = new UIView();

            redDot.Frame               = new CGRect(20, 120, 20, 20);
            redDot.Alpha               = 0;
            redDot.BackgroundColor     = UIColor.Red;
            redDot.Layer.MasksToBounds = true;
            redDot.Layer.CornerRadius  = redDot.Layer.Bounds.Width / 2;
            View.AddSubview(redDot);

            var redDotTwo = new UIView();

            redDotTwo.Frame               = new CGRect(20, 120, 20, 20);
            redDotTwo.Alpha               = 0;
            redDotTwo.BackgroundColor     = UIColor.Red;
            redDotTwo.Layer.MasksToBounds = true;
            redDotTwo.Layer.CornerRadius  = redDotTwo.Layer.Bounds.Width / 2;
            View.AddSubview(redDotTwo);

            var redDotThree = new UIView();

            redDotThree.Frame               = new CGRect(20, 120, 20, 20);
            redDotThree.Alpha               = 0;
            redDotThree.BackgroundColor     = UIColor.Red;
            redDotThree.Layer.MasksToBounds = true;
            redDotThree.Layer.CornerRadius  = redDotThree.Layer.Bounds.Width / 2;
            View.AddSubview(redDotThree);

            var whitePhone = new UIImageView(UIImage.FromBundle("PhoneWhiteLarge"));

            whitePhone.ContentMode = UIViewContentMode.ScaleToFill;
            whitePhone.Frame       = new CGRect(View.Frame.GetMaxX() - 120, View.Frame.GetMidY() - 100, 100, 210);
            whitePhone.Alpha       = 0;
            View.AddSubview(whitePhone);

            var arrowImageView = new UIImageView(UIImage.FromBundle("ArrowWhite"));

            arrowImageView.Transform = CGAffineTransform.MakeRotation(1.5708f);
            arrowImageView.Frame     = new CGRect(View.Frame.GetMaxX() - 70, 40, 40, 100);
            arrowImageView.Alpha     = 0;
            View.AddSubview(arrowImageView);

            var enablePushNotificaionsButton = new UIButton(UIButtonType.System);

            enablePushNotificaionsButton.SetTitle("Enable\nPush Notificaions", new UIControlState());
            enablePushNotificaionsButton.SetTitleColor(UIColor.White, new UIControlState());
            enablePushNotificaionsButton.TitleLabel.Font          = UIFont.FromName("Avenir-Medium", 18);
            enablePushNotificaionsButton.TitleLabel.Lines         = 0;
            enablePushNotificaionsButton.TitleLabel.LineBreakMode = UILineBreakMode.WordWrap;
            enablePushNotificaionsButton.TitleLabel.TextAlignment = UITextAlignment.Center;
            enablePushNotificaionsButton.Frame          = new CGRect(20, View.Frame.GetMidY(), whitePhone.Frame.X - 20, 50);
            enablePushNotificaionsButton.Alpha          = 0;
            enablePushNotificaionsButton.TouchUpInside += (sender, e) =>
            {
                if (!PushNotDetermined)
                {
                    return;
                }

                var appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate;
                appDelegate.SetUpPushNotificaions();
                enablePushNotificaionsButton.Alpha = 0;
            };
            View.AddSubview(enablePushNotificaionsButton);


            UIView.Animate(animationDuration, () =>
            {
                get_notified_label.Alpha           = 1;
                whitePhone.Alpha                   = 1;
                redDot.Alpha                       = 1;
                redDotTwo.Alpha                    = 1;
                redDotThree.Alpha                  = 1;
                enablePushNotificaionsButton.Alpha = PushNotDetermined ? 1 : 0;
            }, () =>
            {
                if (Cancelled)
                {
                    return;
                }

                UIView.Animate(animationDuration / 3, () =>
                {
                    redDot.Frame = new CGRect(whitePhone.Center, redDot.Frame.Size);
                }, () =>
                {
                    if (Cancelled)
                    {
                        return;
                    }

                    UIView.Animate(animationDuration / 3, () =>
                    {
                        redDotTwo.Frame = new CGRect(whitePhone.Center, redDotTwo.Frame.Size);
                    }, () =>
                    {
                        if (Cancelled)
                        {
                            return;
                        }

                        UIView.Animate(animationDuration / 3, () =>
                        {
                            redDotThree.Frame = new CGRect(whitePhone.Center, redDotThree.Frame.Size);
                        }, () =>
                        {
                            if (Cancelled)
                            {
                                return;
                            }

                            UIView.Animate(animationDuration, () =>
                            {
                                get_notified_label.Alpha = 0;
                                whitePhone.Alpha         = 0;
                                redDot.Alpha             = 0;
                                redDotTwo.Alpha          = 0;
                                redDotThree.Alpha        = 0;

                                SlinkLogoImageView.Alpha = 0;
                            }, () =>
                            {
                                arrowImageView.Alpha = 1;
                                NavigationItem.RightBarButtonItem = new UIBarButtonItem(Strings.Basic.lets_go, UIBarButtonItemStyle.Plain, (sender, e) =>
                                {
                                    Cancelled = true;

                                    removeAllSubviews(false, () =>
                                    {
                                        ApplicationExtensions.EnterApplication(false, true);
                                    });
                                });
                            });
                        });
                    });
                });
            });
        }