public override void ViewDidLoad () { base.ViewDidLoad(); viewModel = ServiceContainer.Resolve<DetailsViewModel>(); UITabBar.Appearance.SelectedImageTintColor = UIColor.FromRGB(0.46f, 0.27f, 0.13f); moreButton = new UIBarButtonItem (UIImage.FromBundle("more"), UIBarButtonItemStyle.Plain, OpenPlaceOptions); shareButton = new UIBarButtonItem (UIBarButtonSystemItem.Action, SharePlaceInfo); NavigationItem.RightBarButtonItems = new [] { moreButton, shareButton }; #if !DEBUG Xamarin.Insights.Track ("AppNav", new Dictionary<string,string> { { "page", "details" }, { "name", viewModel.Place.Name }, }); #endif }
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 }
public override void ViewWillAppear (bool animated) { base.ViewWillAppear(animated); // scroll up to hide the header TableView.ContentInset = new UIEdgeInsets { Bottom = bottomContentInset, Top = topContentInset }; TableView.SetContentOffset(new CGPoint (0, tableHeaderHeight - topContentInset), false); viewModel = ServiceContainer.Resolve<DetailsViewModel>(); SetInformation(); SetOpenDays(); SetLocation(); SetTableHeader(); #if !DEBUG Xamarin.Insights.Track ("AppNav", new Dictionary<string,string> { { "page", "info" }, { "name", viewModel.Place.Name }, }); #endif }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { viewModel = ServiceContainer.Resolve<DetailsViewModel> (); var root = inflater.Inflate (Resource.Layout.fragment_details, container, false); mapFragment = root.FindViewById<MapView> (Resource.Id.map); mapFragment.OnCreate (savedInstanceState); var name = root.FindViewById<TextView> (Resource.Id.name); var reviews = root.FindViewById<TextView> (Resource.Id.rating); image = root.FindViewById<ImageView> (Resource.Id.image); var address = root.FindViewById<TextView> (Resource.Id.address); var priceHours = root.FindViewById<TextView> (Resource.Id.price_hours); var phone = root.FindViewById<TextView> (Resource.Id.phone_number); var website = root.FindViewById<TextView> (Resource.Id.website); var googlePlus = root.FindViewById<TextView> (Resource.Id.google_plus); var monday = root.FindViewById<TextView> (Resource.Id.monday); var tuesday = root.FindViewById<TextView> (Resource.Id.tuesday); var wednesday = root.FindViewById<TextView> (Resource.Id.wednesday); var thursday = root.FindViewById<TextView> (Resource.Id.thursday); var friday = root.FindViewById<TextView> (Resource.Id.friday); var saturday = root.FindViewById<TextView> (Resource.Id.saturday); var sunday = root.FindViewById<TextView> (Resource.Id.sunday); var allHours = root.FindViewById<LinearLayout> (Resource.Id.all_hours); var allWeb = root.FindViewById<LinearLayout> (Resource.Id.all_web); var distance = root.FindViewById<TextView> (Resource.Id.distance); mainScroll = root.FindViewById<FilterScrollView> (Resource.Id.main_scroll); if (Math.Abs (Position.Latitude) < double.Epsilon && Math.Abs (Position.Longitude) < double.Epsilon) distance.Text = string.Empty; else { var dis = Place.GetDistance (Position.Latitude, Position.Longitude, CultureInfo.CurrentCulture.Name != "en-US" ? CoffeeFilter.Shared.GeolocationUtils.DistanceUnit.Kilometers : CoffeeFilter.Shared.GeolocationUtils.DistanceUnit.Miles).ToString ("##.###", CultureInfo.CurrentUICulture); distance.Text = string.Format (Resources.GetString (Resource.String.distance_away), dis); } if (string.IsNullOrWhiteSpace (Place.Rating.ToString ())) reviews.Visibility = ViewStates.Gone; else reviews.Text = string.Format (Resources.GetString (Resource.String.based_on_review), Place.Rating, Place.UserRatingsCount); name.Text = Place.Name; phone.Text = Place.PhoneNumberFormatted; if (!string.IsNullOrWhiteSpace (phone.Text)) { phone.Clickable = true; phone.Click += (sender, e) => { try { #if !DEBUG Xamarin.Insights.Track ("Click", new Dictionary<string,string> { { "item", "phone" }, { "name", Place.Name }, }); #endif var intent = new Intent(Intent.ActionDial); var uri = Android.Net.Uri.Parse ("tel:" + (string.IsNullOrWhiteSpace (Place.InternationalPhoneNumber) ? phone.Text : Place.InternationalPhoneNumber)); intent.SetData(uri); intent.AddFlags(ActivityFlags.ClearWhenTaskReset); Activity.StartActivity(intent); } catch (Exception ex) { ex.Data ["call"] = "phone"; Xamarin.Insights.Report (ex); } }; } address.Text = viewModel.ShortAddress; priceHours.Text = viewModel.OpenHours; if (Place.HasImage) Koush.UrlImageViewHelper.SetUrlDrawable (image, Place.MainImage); if (Place.OpeningHours == null || Place.OpeningHours.WeekdayText.Count != 7) { allHours.Visibility = ViewStates.Gone; } else { monday.Text = GetTime (Place.OpeningHours.WeekdayText [0]); tuesday.Text = GetTime (Place.OpeningHours.WeekdayText [1]); wednesday.Text = GetTime (Place.OpeningHours.WeekdayText [2]); thursday.Text = GetTime (Place.OpeningHours.WeekdayText [3]); friday.Text = GetTime (Place.OpeningHours.WeekdayText [4]); saturday.Text = GetTime (Place.OpeningHours.WeekdayText [5]); sunday.Text = GetTime (Place.OpeningHours.WeekdayText [6]); } if (string.IsNullOrWhiteSpace (Place.Website) && string.IsNullOrWhiteSpace (Place.Url)) allWeb.Visibility = ViewStates.Gone; if (string.IsNullOrWhiteSpace (Place.Website)) { website.Visibility = ViewStates.Gone; root.FindViewById<TextView> (Resource.Id.website_header).Visibility = ViewStates.Gone; } else { website.Text = Place.Website; } if (string.IsNullOrWhiteSpace (Place.Url)) { googlePlus.Visibility = ViewStates.Gone; root.FindViewById<TextView> (Resource.Id.google_plus_header).Visibility = ViewStates.Gone; } else { googlePlus.Text = "plus.google.com"; } website.Clickable = true; website.Click += (sender, e) => { try { #if !DEBUG Xamarin.Insights.Track ("Click", new Dictionary<string,string> { { "item", "website" }, { "name", Place.Name }, }); #endif var intent = new Intent (Intent.ActionView); intent.SetData (Android.Net.Uri.Parse (Place.Website)); Activity.StartActivity (intent); } catch (Exception ex) { ex.Data ["call"] = "website"; Xamarin.Insights.Report (ex); } }; googlePlus.Clickable = true; googlePlus.Click += (sender, e) => { try { Xamarin.Insights.Track ("Click", new Dictionary<string,string> { { "item", "google plus" }, { "name", Place.Name }, }); var intent = new Intent (Intent.ActionView); intent.SetData (Android.Net.Uri.Parse (Place.Url)); Activity.StartActivity (intent); } catch (Exception ex) { ex.Data ["call"] = "google+"; Xamarin.Insights.Report (ex); } }; var panorama = root.FindViewById<Button> (Resource.Id.panorama); panorama.Click += (sender, e) => { var intent = new Intent (Activity, typeof(PanoramaActivity)); intent.PutExtra ("lat", (double)Place.Geometry.Location.Latitude); intent.PutExtra ("lng", (double)Place.Geometry.Location.Longitude); Activity.StartActivity (intent); }; if (!Place.HasImage) { var paddingLayout = root.FindViewById<LinearLayout> (Resource.Id.padding_layout); paddingLayout.SetPadding (0, 0, 0, 0); } return root; }
public DetailsAdapter(Context context, Android.Support.V4.App.FragmentManager fm, DetailsViewModel viewModel) : base(fm) { titles = context.Resources.GetTextArray (Resource.Array.sections); this.viewModel = viewModel; }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); try{ viewModel = ServiceContainer.Resolve<DetailsViewModel> (); } catch{ viewModel = new DetailsViewModel (); ServiceContainer.RegisterScoped (viewModel); } adapter = new DetailsAdapter (this, SupportFragmentManager, viewModel); pager = FindViewById<ViewPager> (Resource.Id.pager); var tabs = FindViewById<TabLayout> (Resource.Id.tabs); pager.Adapter = adapter; tabs.SetupWithViewPager (pager); pager.OffscreenPageLimit = 3; var layoutParameters = new Android.Support.V7.Widget.Toolbar.LayoutParams ( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent, (int)(GravityFlags.Top | GravityFlags.Right)); var progressBar = new ProgressBar (this, null, Android.Resource.Attribute.ProgressBarStyleSmallTitle) { Indeterminate = true, LayoutParameters = layoutParameters }; SupportActionBar.SetDisplayShowCustomEnabled (true); SupportActionBar.CustomView = progressBar; SupportActionBar.Title = viewModel.Place == null ? string.Empty : viewModel.Place.Name; #if !DEBUG Xamarin.Insights.Track ("AppNav", new Dictionary<string,string> { { "page", "details" }, { "name", SupportActionBar.Title } }); #endif client = new GoogleApiClientBuilder (this) .AddConnectionCallbacks (this) .EnableAutoManage (this, 0, this) .AddApi (AppInviteClass.API) .Build (); }
async void OnPlaceSelected () { var detailsViewModel = new DetailsViewModel { Position = viewModel.Position, Place = currentPlace }; ShowProgress(true); bool success = await detailsViewModel.RefreshPlace(); if (!success) { var alertController = UIAlertController.Create(string.Empty, "unable_to_get_details".LocalizedString("Details request failure message"), UIAlertControllerStyle.Alert); alertController.AddAction(UIAlertAction.Create("ok".LocalizedString("OK title for button"), UIAlertActionStyle.Destructive, null)); ShowViewController(alertController, this); return; } ServiceContainer.RegisterScoped<DetailsViewModel>(detailsViewModel); ShowViewController(Storyboard.Instantiate<PlaceDetailsViewController>(), this); ShowProgress(false); }