コード例 #1
0
        private void CreateNotificationContent(UNMutableNotificationContent content, RestaurantMO restaurantMO)
        {
            content.Title    = "Restaurant Recommendation";
            content.Subtitle = "Try new food today";
            content.Body     = "I recommend you to check out " + restaurantMO.Name + ".The restaurant is one of your favorites. It is located at " + restaurantMO.Location + " .Would you like to give it a try?";
            content.Sound    = UNNotificationSound.Default;
            NSDictionary userInfo = new NSDictionary("phone", restaurantMO.Phone);

            content.UserInfo = userInfo;
        }
コード例 #2
0
 public void SetWithRestaurant(RestaurantMO restaurantMO)
 {
     _restaurantMO            = restaurantMO;
     ThumbnailImageView.Image = _restaurantMO.GetImage();
     NameLabel.Text           = _restaurantMO.Name;
     NameLabel.Lines          = 0;
     TypeLabel.Text           = _restaurantMO.Type;
     TypeLabel.Lines          = 0;
     LocationLabel.Text       = _restaurantMO.Location;
     LocationLabel.Lines      = 0;
 }
コード例 #3
0
        private async void InsertNewRestaurant(RestaurantMO restaurantMO)
        {
            var dataBaseConnection = DataBaseConnection.Instance;

            if (dataBaseConnection != null)
            {
                dataBaseConnection.Conn.Insert(restaurantMO);
            }
            ////Required by the async method
            await Task.Delay(1);

            InvokeOnMainThread(() => { CreateAddedRestaurantAlertController(restaurantMO.Name); });
        }
コード例 #4
0
        private void CustomizeBackgroundImage()
        {
            BackgroundImageView.Image = RestaurantMO.GetImage();
            var blurEffect     = UIBlurEffect.FromStyle(UIBlurEffectStyle.Light);
            var blurEffectView = new UIVisualEffectView(blurEffect);

            blurEffectView.Frame = View.Bounds;
            BackgroundImageView.AddSubview(blurEffectView);

            blurEffectView.TranslatesAutoresizingMaskIntoConstraints = false;
            blurEffectView.TopAnchor.ConstraintEqualTo(BackgroundImageView.TopAnchor).Active       = true;
            blurEffectView.BottomAnchor.ConstraintEqualTo(BackgroundImageView.BottomAnchor).Active = true;
            blurEffectView.LeftAnchor.ConstraintEqualTo(BackgroundImageView.LeftAnchor).Active     = true;
            blurEffectView.RightAnchor.ConstraintEqualTo(BackgroundImageView.RightAnchor).Active   = true;
        }
コード例 #5
0
        private void SetNewRestaurantData()
        {
            RestaurantMO restaurantMO = new RestaurantMO()
            {
                Name      = RestaurantNameTextField.Text,
                Type      = RestaurantTypeTextField.Text,
                Location  = RestaurantAddressTextField.Text,
                Phone     = RestaurantPhoneTextField.Text,
                Summary   = RestaurantDescriptionTextView.Text,
                IsVisited = false,
                Image     = PhotoImageView.Image.AsPNG().ToArray(),
                Rating    = string.Empty
            };

            InsertNewRestaurant(restaurantMO);
        }
コード例 #6
0
        public static NSObject[] GetActivityItems(this RestaurantMO restaurantMO)
        {
            var defaultText   = AppResources.CheckInWarning + restaurantMO.Name;
            var activityItems = new NSObject[] { };
            var imageToLoad   = restaurantMO.GetImage();

            if (imageToLoad != null)
            {
                activityItems = new NSObject[] { (new NSString(defaultText)), imageToLoad };
            }
            else
            {
                activityItems = new NSObject[] { (new NSString(defaultText)) };
            }

            return(activityItems);
        }
コード例 #7
0
        private void AddingPhotoToNotification(RestaurantMO restaurantMO, UNMutableNotificationContent content)
        {
            var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var suggestedRestaurantImage = Path.Combine(documents, "suggested-restaurant.jpg");

            var image = restaurantMO.GetImage();

            if (image != null)
            {
                try
                {
                    NSError err = null;
                    image.AsJPEG(1)?.Save(suggestedRestaurantImage, false, out err);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                try
                {
                    NSError error;
                    UNNotificationAttachmentOptions attachmentOptions = new UNNotificationAttachmentOptions();
                    var finalImage      = "file:///" + suggestedRestaurantImage;
                    var restaurantImage = UNNotificationAttachment.FromIdentifier("restaurantImage", new NSUrl(finalImage), attachmentOptions, out error);
                    if (restaurantImage != null)
                    {
                        content.Attachments = new[] { restaurantImage };
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
コード例 #8
0
        public static UIImage GetImage(this RestaurantMO restaurantMO)
        {
            NSData data = NSData.FromArray(restaurantMO.Image);

            return(UIImage.LoadFromData(data));
        }
コード例 #9
0
        public static UIImage GetCheckmarkImage(this RestaurantMO restaurantMO)
        {
            UIImage image = restaurantMO.IsVisited ? UIImage.FromBundle("CheckmarkImageView") : null;

            return(image);
        }
コード例 #10
0
        public static UIImage GetCheckInImage(this RestaurantMO restaurantMO)
        {
            UIImage image = restaurantMO.IsVisited ? UIImage.FromBundle("undo") : UIImage.FromBundle("tick");

            return(image);
        }