Esempio n. 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            placeViews = new List <PlaceView> ();

            coffeeAnimation = CoffeeAnimationView.GetView(this);

            NavigationController.NavigationBar.TintColor = tintColor;

            var appearance = UIBarButtonItem.AppearanceWhenContainedIn(typeof(UINavigationBar));

            appearance.SetTitleTextAttributes(new UITextAttributes {
                TextColor = tintColor,
                Font      = UIFont.FromName("HelveticaNeue-Light", 20f)
            }, UIControlState.Normal);

            MapView.ShowsUserLocation = true;

            try {
                viewModel = ServiceContainer.Resolve <CoffeeFilterViewModel>();
            } catch {
                viewModel = new CoffeeFilterViewModel();
                ServiceContainer.Register <CoffeeFilterViewModel>(viewModel);
            }


            var searchButton     = NavigationItem.RightBarButtonItem;
            var navigationButton = new UIBarButtonItem(UIImage.FromBundle("near"), UIBarButtonItemStyle.Plain, OpenMaps);

            NavigationItem.SetRightBarButtonItems(new [] { searchButton, navigationButton }, false);

            RefreshData(true);
        }
Esempio n. 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

                        #if DEBUG
            Xamarin.Insights.Initialize("ef02f98fd6fb47ce8624862ab7625b933b6fb21d", this);
                        #else
            Xamarin.Insights.Initialize("8da86f8b3300aa58f3dc9bbef455d0427bb29086", this);
                        #endif

            mapView = FindViewById <MapView> (Resource.Id.map);
            mapView.OnCreate(bundle);

            mapView.Visibility = ViewStates.Invisible;
            viewModel          = new CoffeeFilterViewModel();
            ServiceContainer.Register <CoffeeFilterViewModel> (viewModel);
            adapter                = new PlacesPagerAdapter(SupportFragmentManager, viewModel);
            pager                  = FindViewById <ViewPager> (Resource.Id.pager);
            pager.Adapter          = adapter;
            progressBar            = FindViewById <ImageView> (Resource.Id.progressBar);
            errorImage             = FindViewById <ImageView> (Resource.Id.error);
            coffeeProgress         = (AnimationDrawable)progressBar.Background;
            progressBar.Visibility = ViewStates.Gone;

            pager.PageSelected           += (sender, e) => UpdateMap(e.Position);
            pager.PageScrollStateChanged += (sender, e) => {
                if (e.State == (int)ScrollState.TouchScroll)
                {
                    refresher.Enabled = false;
                }
                else
                {
                    refresher.Enabled = true;
                }
            };

            refresher = FindViewById <SwipeRefreshLayout> (Resource.Id.refresher);
            refresher.SetColorSchemeColors(Resource.Color.accent);
            refresher.Refresh += (sender, args) => {
                RefreshData(true);
                refresher.PostDelayed(() => {
                    refresher.Refreshing = false;
                }, 250);
            };

            SupportActionBar.SetDisplayHomeAsUpEnabled(false);
            SupportActionBar.SetHomeButtonEnabled(false);
            mapView.GetMapAsync(this);
            CheckGooglePlayServices();

            // No savedInstanceState, so it is the first launch of this activity
            if (bundle == null && AppInviteReferral.HasReferral(Intent))
            {
                // In this case the referral data is in the intent launching the MainActivity,
                // which means this user already had the app installed. We do not have to
                // register the Broadcast Receiver to listen for Play Store Install information
                LaunchDeepLinkActivity(Intent);
            }
        }
        public ActionResult Filter(CoffeeFilterViewModel filter)
        {
            if (!Request.IsAjaxRequest())
            {
                return(HttpNotFound());
            }

            var items = GetFilteredCoffees(filter);

            return(PartialView("CoffeeList", items));
        }
        // GET: Coffees
        public ActionResult Index()
        {
            var items  = GetFilteredCoffees(null);
            var filter = new CoffeeFilterViewModel();

            filter.Load();

            return(View(new ProductListViewModel
            {
                Filter = filter,
                Items = items
            }));
        }
        public void GetWhereCondition_EmptyViewMode_EmptyWhereCondition()
        {
            var filter = new CoffeeFilterViewModel();

            filter.Load();

            var where = filter.GetWhereCondition();

            CMSAssert.All(
                () => Assert.IsNotNull(where),
                () => Assert.IsEmpty(where.ToString(true))
                );
        }
Esempio n. 6
0
        // GET: Coffees
        public ActionResult Index([FromServices] IStringLocalizer <SharedResources> localizer)
        {
            var items  = GetFilteredCoffees(null);
            var filter = new CoffeeFilterViewModel();

            filter.Load(localizer);

            return(View(new ProductListViewModel
            {
                Filter = filter,
                Items = items
            }));
        }
        public void GetWhereCondition_SetUpDecaf_RestrictionInWhereCondition()
        {
            var filter = new CoffeeFilterViewModel
            {
                OnlyDecaf = true
            };

            filter.Load();

            var where = filter.GetWhereCondition();

            CMSAssert.All(
                () => Assert.IsNotNull(where),
                () => Assert.AreEqual("[CoffeeIsDecaf] = 1", where.ToString(true))
                );
        }
        public void GetWhereCondition_SetUpCoffeeProcessingType_RestrictionInWhereCondition()
        {
            var filter = new CoffeeFilterViewModel();

            filter.Load();

            filter.ProcessingTypes[0].IsChecked = true;
            filter.ProcessingTypes[1].IsChecked = false;
            filter.ProcessingTypes[2].IsChecked = true;

            var where = filter.GetWhereCondition();

            CMSAssert.All(
                () => Assert.IsNotNull(where),
                () => Assert.AreEqual("[CoffeeProcessing] IN (N'Washed', N'Natural')", where.ToString(true))
                );
        }
        public void Load_FilterContainsCorrectOptions()
        {
            var filter = new CoffeeFilterViewModel();

            filter.Load();

            var washed     = filter.ProcessingTypes.FirstOrDefault(checkbox => checkbox.Value == "Washed");
            var semiwashed = filter.ProcessingTypes.FirstOrDefault(checkbox => checkbox.Value == "Semiwashed");
            var natural    = filter.ProcessingTypes.FirstOrDefault(checkbox => checkbox.Value == "Natural");

            CMSAssert.All(
                () => Assert.AreEqual(3, filter.ProcessingTypes.Length),
                () => Assert.IsNotNull(washed),
                () => Assert.IsNotNull(semiwashed),
                () => Assert.IsNotNull(natural)
                );
        }
Esempio n. 10
0
        public void PopulateWithData(Place place)
        {
            var coffeeFilterViewModel = ServiceContainer.Resolve <CoffeeFilterViewModel>();

            DistanceLabel.Text = CoffeeFilterViewModel.GetDistanceToPlace(place, coffeeFilterViewModel.Position);

            if (place.Rating != 0)
            {
                RatingLabel.Text    = place.Rating.ToString();
                StarImageView.Image = UIImage.FromBundle("i_star");
            }
            else
            {
                RatingLabel.Hidden   = true;
                StarImageView.Hidden = true;
            }

            placeButton.SetTitle(place.Name, UIControlState.Normal);
        }
Esempio n. 11
0
        public override void Awake(NSObject context)
        {
            viewModel = ServiceContainer.Resolve <DetailsViewModel> ();

            RatingLabel.SetText(viewModel.Place.Rating.ToString());
            DistanceLabel.SetText(CoffeeFilterViewModel.GetDistanceToPlace(viewModel.Place, viewModel.Position));
            PlaceNameLabel.SetText(viewModel.Place.Name);

            SetMapRegion();
            AddMapAnnotation();
            EnableButtons(false);
            UpdatePlaceInfo();

                        #if !DEBUG
            Xamarin.Insights.Track("AppNav", new Dictionary <string, string> {
                { "page", "details" },
                { "name", viewModel.Place.Name }
            });
                        #endif
        }
Esempio n. 12
0
        private ICoffeeRepository MockDataSource(SKUInfo skuInfo)
        {
            Fake().DocumentType <Coffee>(Coffee.CLASS_NAME);

            var coffee1 = TreeNode.New <Coffee>().With(x =>
            {
                x.Fields.IsDecaf = false;
                x.DocumentName   = COFFEE_TITLE1;
                x.SKU            = skuInfo;
            });

            var coffee2 = TreeNode.New <Coffee>().With(x =>
            {
                x.Fields.IsDecaf = true;
                x.DocumentName   = COFFEE_TITLE2;
                x.SKU            = skuInfo;
            });

            var repository = Substitute.For <ICoffeeRepository>();

            // Filter without restriction
            mFilter = Substitute.For <CoffeeFilterViewModel>();
            repository.GetCoffees(mFilter).Returns(new List <Coffee> {
                coffee1, coffee2
            });

            // Filter for decafed coffees
            mFilter2 = Substitute.For <CoffeeFilterViewModel>();
            repository.GetCoffees(mFilter2).Returns(new List <Coffee> {
                coffee2
            });

            // There is no coffee for this filter
            mFilter3 = Substitute.For <CoffeeFilterViewModel>();
            repository.GetCoffees(mFilter3).Returns(new List <Coffee>());

            return(repository);
        }
Esempio n. 13
0
 public PlacesPagerAdapter(Android.Support.V4.App.FragmentManager fm, CoffeeFilterViewModel vm) : base(fm)
 {
     ViewModel = vm;
 }