コード例 #1
0
        public void StopSearching()
        {
            Searching           = false;
            ShouldStopSearching = true;

            StatusButton.Hidden = true;
            StatusButton.SetTitle(null, new UIControlState());

            shape?.RemoveAllAnimations();
            shape?.RemoveFromSuperLayer();
        }
コード例 #2
0
        async void StartSearching()
        {
            if (Searching)
            {
                return;
            }
            Searching           = true;
            ShouldStopSearching = false;

            if (!IsSufficentPermissionGranted())
            {
                StatusButton.Hidden = false;
                StatusButton.SetTitle("Location Permission Necessary. \n Go to Settings", new UIControlState());
                return;
            }

            shape             = new CAShapeLayer();
            shape.Bounds      = new CGRect(0, 0, PhoneImageView.Frame.Width, PhoneImageView.Frame.Height);
            shape.Position    = new CGPoint(PhoneImageView.Frame.Width / 2, PhoneImageView.Frame.Height / 2);
            shape.Path        = UIBezierPath.FromOval(PhoneImageView.Bounds).CGPath;
            shape.StrokeColor = UIColor.White.CGColor;
            shape.LineWidth   = (nfloat).5;
            shape.FillColor   = UIColor.Clear.CGColor;
            PhoneImageView.Layer.AddSublayer(shape);

            CABasicAnimation grow = CABasicAnimation.FromKeyPath("transform.scale");

            grow.From                = NSObject.FromObject(20);
            grow.Duration            = 2;
            grow.To                  = NSObject.FromObject(1);
            grow.FillMode            = CAFillMode.Forwards;
            grow.RepeatCount         = 10000;
            grow.RemovedOnCompletion = false;
            shape.AddAnimation(grow, "grow");

            StatusButton.Hidden = false;
            StatusButton.SetTitle("Searching for people \n sharing nearby", new UIControlState());

            while (!ShouldStopSearching && View.Window != null)
            {
                await Shared.GetNearbyTransactions();

                StopSearchingIfCardsFound();

                Console.WriteLine("GOT");
                await Task.Delay(TimeSpan.FromSeconds(5));

                Console.WriteLine("DONE");
            }
        }